private async Task MainAsync() { DeserializeSettings(); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose, AlwaysDownloadUsers = true, MessageCacheSize = 50 }); _commandService = new CommandService(new CommandServiceConfig { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Async }); _services = ConfigureServices(); _commandHandlingService = _services.GetRequiredService <CommandHandlingService>(); _services.GetRequiredService <ModerationService>(); await _commandHandlingService.Initialize(); _client.Log += Logger; await _client.LoginAsync(TokenType.Bot, _settings.Token); await _client.StartAsync(); _client.Ready += () => { Console.WriteLine("Bot is connected"); //_audio.Music(); return(Task.CompletedTask); }; await Task.Delay(-1); }
public BotService(ILogger <BotService> logger, IOptions <DiscordSettings> discordSettings, DiscordSocketClient client, CommandHandlingService commandHandlingService) { _logger = logger; this.discordSettings = discordSettings.Value; this.client = client; this.commandHandlingService = commandHandlingService; }
private async Task MainAsync() { await using ServiceProvider services = Initialize.BuildServiceProvider(); _client = services.GetService <DiscordSocketClient>(); _client.Log += Log; _commands = services.GetService <CommandHandlingService>(); await _commands.InstallCommandsAsync(); await _client.LoginAsync(TokenType.Bot, services.GetService <BotConfig>().Token); await _client.StartAsync(); await Task.Delay(-1); }