2019-01-06 18:51:46 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using CompatBot.Database;
|
|
|
|
|
using CompatBot.Utils;
|
|
|
|
|
using DSharpPlus.EventArgs;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace CompatBot.EventHandlers
|
|
|
|
|
{
|
|
|
|
|
internal static class Greeter
|
|
|
|
|
{
|
|
|
|
|
public static async Task OnMemberAdded(GuildMemberAddEventArgs args)
|
|
|
|
|
{
|
2019-11-25 13:07:01 +00:00
|
|
|
|
using var db = new BotDb();
|
|
|
|
|
var explanation = await db.Explanation.FirstOrDefaultAsync(e => e.Keyword == "motd").ConfigureAwait(false);
|
|
|
|
|
if (explanation != null)
|
2019-01-06 18:51:46 +00:00
|
|
|
|
{
|
2019-11-25 13:07:01 +00:00
|
|
|
|
var dm = await args.Member.CreateDmChannelAsync().ConfigureAwait(false);
|
|
|
|
|
await dm.SendMessageAsync(explanation.Text, explanation.Attachment, explanation.AttachmentFilename).ConfigureAwait(false);
|
|
|
|
|
Config.Log.Info($"Sent motd to {args.Member.GetMentionWithNickname()}");
|
2019-01-06 18:51:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|