/// <summary> /// Apply the bots configuration and start him asyncronously /// </summary> /// <returns></returns> public async static Task StartBotAsync() { AttributeLoader.LoadCustomAttributes(); Client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Debug }); Commands = new CommandService(); commandHandler = new CommandHandler(Client, Commands); AppConfig = await SettingsFactory.CreateAsync(); context = new DataContext(); context.Database.Migrate(); /* ensure the db exists */ if (string.IsNullOrWhiteSpace(AppConfig.Token)) { Console.WriteLine("Failed to start... Bot Token was missing.\n\n" + "Troubleshooting:\n" + "If running on Windows or Linux make sure to fill in the Settings.xml file (generated after first launch)\n" + "If running on Docker make sure to pass in the BOT_TOKEN variable"); Environment.Exit(-1); } await AttachEventHandlers(); await Client.SetGameAsync(AppConfig.Activity); await Client.LoginAsync(TokenType.Bot, AppConfig.Token); await commandHandler.InstallCommandsAsync(); await Client.StartAsync(); MessagePipe.MessageRecieved += Logger.Debug; /* hook el-cheapo logs */ new Thread(() => { Thread.CurrentThread.IsBackground = true; Thread.Sleep(10000); GameNotifierService.QueryService.StartService(); Logger.Debug("Game notifier service has been started"); }).Start(); //wait infinitely I think? await Task.Delay(-1); }