Ejemplo n.º 1
0
        public async Task RunBotAsync()
        {
            var service = new BotServices();

            service.LoadBotConfiguration();

            Client = new DiscordClient(new DiscordConfiguration
            {
                Token                   = TokenHandler.Tokens.DiscordToken,
                TokenType               = TokenType.Bot,
                AutoReconnect           = true,
                LogLevel                = LogLevel.Info,
                UseInternalLogHandler   = false,
                GatewayCompressionLevel = GatewayCompressionLevel.Stream,
                LargeThreshold          = 250
            });
            Client.Ready         += Client_Ready;
            Client.ClientErrored += Client_ClientError;
            Client.DebugLogger.LogMessageReceived += Client_LogMessageHandler;
            Client.UseInteractivity(new InteractivityConfiguration
            {
                PaginationBehaviour = PaginationBehaviour.Ignore, // Default pagination behavior to just ignore the reactions
                Timeout             = TimeSpan.FromMinutes(2)     // Default pagination timeout to 2 minutes
            });

            Commands = Client.UseCommandsNext(new CommandsNextConfiguration
            {
                PrefixResolver      = PrefixResolverAsync, // Set the command prefix that will be used by the bot
                EnableDms           = false,               // Set the boolean for responding to direct messages
                EnableMentionPrefix = true,                // Set the boolean for mentioning the bot as a command prefix
                CaseSensitive       = false,
            });
            Commands.CommandExecuted += Commands_CommandExecuted;
            Commands.CommandErrored  += Commands_CommandErrored;
            Commands.RegisterCommands <BotModule>();
            Commands.RegisterCommands <ServerModule>();
            Commands.RegisterCommands <ChannelModule>();
            Commands.RegisterCommands <RoleModule>();
            Commands.RegisterCommands <UserModule>();
            //Commands.RegisterCommands<AmiiboModule>();
            //Commands.RegisterCommands<DictionaryModule>();
            //Commands.RegisterCommands<EmojiModule>();
            //Commands.RegisterCommands<GoodReadsModule>();
            //Commands.RegisterCommands<GoogleModule>();
            //Commands.RegisterCommands<ImgurModule>();
            //Commands.RegisterCommands<MathModule>();
            //Commands.RegisterCommands<MiscModule>();
            //Commands.RegisterCommands<NASAModule>();
            //Commands.RegisterCommands<OMDBModule>();
            //Commands.RegisterCommands<PokemonModule>();
            //Commands.RegisterCommands<PollModule>();
            //Commands.RegisterCommands<RedditModule>();
            //Commands.RegisterCommands<SimpsonsModule>();
            //Commands.RegisterCommands<SpeedrunModule>();
            //Commands.RegisterCommands<SteamModule>();
            //Commands.RegisterCommands<TeamFortressModule>();
            //Commands.RegisterCommands<TwitchModule>();
            //Commands.RegisterCommands<WikipediaModule>();
            //Commands.RegisterCommands<YouTubeModule>();
            Commands.RegisterCommands <YoutubeBotCommands>();
            Commands.SetHelpFormatter <HelpFormatter>();

            // Start the uptime counter
            Console.Title             = SharedData.Name + " (" + SharedData.Version + ")";
            SharedData.ProcessStarted = DateTime.Now;
            //await SteamService.UpdateSteamListAsync().ConfigureAwait(false);
            //await TeamFortressService.UpdateTF2SchemaAsync().ConfigureAwait(false);
            //await PokemonService.UpdatePokemonListAsync().ConfigureAwait(false);
            await Client.ConnectAsync().ConfigureAwait(false); // Connect and log into Discord

            await Task.Delay(-1).ConfigureAwait(false);        // Prevent the console window from closing
        }