public async Task MainAsync(string apiToken, CancellationToken token) { // Centralize the logic for commands into a separate method. await InitCommands().ConfigureAwait(false); // Login and connect. await _client.LoginAsync(TokenType.Bot, apiToken).ConfigureAwait(false); await _client.StartAsync().ConfigureAwait(false); // Restore Echoes await Task.Delay(5_000, token).ConfigureAwait(false); EchoModule.RestoreChannels(_client); // Restore Logging await Task.Delay(5_000, token).ConfigureAwait(false); LogModule.RestoreLogging(_client); TradeStartModule.RestoreTradeStarting(_client); var game = SysCordInstance.Settings.BotGameStatus; if (!string.IsNullOrWhiteSpace(game)) { await _client.SetGameAsync(game).ConfigureAwait(false); } var app = await _client.GetApplicationInfoAsync().ConfigureAwait(false); SysCordInstance.Manager.Owner = app.Owner.Id; // Wait infinitely so your bot actually stays connected. await MonitorStatusAsync(token).ConfigureAwait(false); }
public async Task MainAsync(string apiToken, CancellationToken token) { // Centralize the logic for commands into a separate method. await InitCommands().ConfigureAwait(false); // Login and connect. await _client.LoginAsync(TokenType.Bot, apiToken).ConfigureAwait(false); await _client.StartAsync().ConfigureAwait(false); // Restore Logging await Task.Delay(5_000, token).ConfigureAwait(false); LogModule.RestoreLogging(_client); var game = SysCordInstance.Self.Hub.Config.DiscordGameStatus; if (!string.IsNullOrWhiteSpace(game)) { await _client.SetGameAsync(game).ConfigureAwait(false); } // Wait infinitely so your bot actually stays connected. await MonitorStatusAsync(token).ConfigureAwait(false); }