public SmashBot(IServiceProvider services) { DBService = (PlayerDBService)services.GetService(typeof(PlayerDBService)); Lobby = (LobbyService)services.GetService(typeof(ILobbyService)); const string tokenKey = "smashbot_token"; string token = ""; #if CONFIG_FILE const string path = "config.json"; if (!File.Exists(path)) { new BotConfig().Save(path); return; } else { token = BotConfig.FromFile(path).Token; } #else token = Environment.GetEnvironmentVariable(tokenKey); if (string.IsNullOrEmpty(token)) { Console.WriteLine($"El token {tokenKey} debe estar registrado en las variables de entorno! El bot no se inició"); return; } #endif var config = new DiscordConfiguration { Token = token, TokenType = TokenType.Bot, AutoReconnect = true }; Client = new DiscordClient(config); Client.Ready += OnClientReady; Client.GuildCreated += OnGuildEntered; Client.GuildDeleted += OnGuildLeave; Client.MessageCreated += Lobby.OnMessage; Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromSeconds(20) }); var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { "s!", "!!" }, EnableDms = false, EnableMentionPrefix = true, Services = services }; var commands = Client.UseCommandsNext(commandsConfig); //commands.RegisterCommands<ReportCommands> (); //commands.RegisterCommands<InfoCommands> (); commands.RegisterCommands <UtilsCommands> (); //commands.RegisterCommands<SmashfestCommands> (); commands.RegisterCommands <LobbyCommands> (); //commands.RegisterCommands<DebugCommands> (); commands.RegisterCommands <TimerCommands> (); Client.ConnectAsync(); }