Ejemplo n.º 1
0
        public async Task Start()
        {
            // Start bot
            Console.Title = $"Wumpus Bot for Discord by Jofairden";

            _config = new BotConfig(Token.BotToken, Token.TestToken);
            await _config.Maintain <BotConfig>();

            await Console.Out.WriteLineAsync($"Start date: {DateTime.UtcNow}");

            await Console.Out.WriteLineAsync($"{oath2Url}?client_id={clientid}&scope=bot");

            // Config client
            _client = new DiscordSocketClient(new DiscordSocketConfig()
            {
                LogLevel         = LogSeverity.Verbose,
                MessageCacheSize = 25,                 // per channel
            });

            // Register events
            _client.Log             += Client_Log;
            _client.JoinedGuild     += Client_JoinedGuild;
            _client.Ready           += Client_Ready;
            _client.LatencyUpdated  += Client_LatencyUpdated;
            _client.UserJoined      += _client_UserJoined;
            _client.MessageReceived += _client_MessageReceived;

            // Login and start
            await _client.LoginAsync(TokenType.Bot, _config.BotToken);

            await _client.StartAsync();

            var map = new DependencyMap();

            _commandHandler = new CommandHandler();
            await _commandHandler.Install(_client, map);

            // Never end app, let bot run.
            await Task.Delay(-1);
        }