using System; using System.Threading.Tasks; using DeukBot4.MessageHandlers; using DeukBot4.MessageHandlers.CommandHandler; using Discord; using Discord.Commands.Builders; using Discord.WebSocket; namespace DeukBot4 { class Program { public static DiscordSocketClient Client { get; private set; } public static Settings Settings { get; private set; } private static void Main(string[] args) { MainAsync().GetAwaiter().GetResult(); } private static async Task MainAsync() { Settings = Settings.FromJsonFile("settings.json"); CommandHandler.Build(); Client = new DiscordSocketClient(); Client.Log += Logger.LogDiscord; Client.Ready += OnReady; Client.MessageReceived += MainHandler.HandleMessage; await Client.LoginAsync(TokenType.Bot, Settings.Token); await Client.StartAsync(); // Block this task until the program is closed. await Task.Delay(-1); } private static async Task OnReady() { await Client.CurrentUser.ModifyAsync(properties => { properties.Username = Settings.Username; }); } } }