Exemplo n.º 1
0
        public async Task <DiscordSocketClient> CreateSocketClientAsync()
        {
            System.Console.WriteLine("Creating Socket Client");
            var client = new DiscordSocketClient();
            var token  = _configurationProvider.GetConfigurationParameter(StaticData.TokenTypeConfigurationKey);
            await client.LoginAsync(TokenType.Bot, token);

            return(client);
        }
Exemplo n.º 2
0
        private async Task OnReady()
        {
            Console.WriteLine("Channel:");
            foreach (var socketGuild in _discordSocketClient.Guilds)
            {
                Console.WriteLine(socketGuild.Id);
                Console.WriteLine(socketGuild.Name);
                foreach (var socketUser in socketGuild.Users)
                {
                    Console.WriteLine(socketUser.Username);
                }
            }

            _mainServer = _discordSocketClient.Guilds.FirstOrDefault(x => x.Name == _configurationProvider.GetConfigurationParameter(StaticData.ServerNameConfigurationKey));
            if (_mainServer == null)
            {
                Console.WriteLine("Main server not found, Logging will not be availale");
            }
            _logChannel = _mainServer.TextChannels.First(x => x.Name == _configurationProvider.GetConfigurationParameter(StaticData.LogChannelConfigurationKey));

            await _discordSocketClient.SetGameAsync("Minecraft 1.7.10");
        }
Exemplo n.º 3
0
        private async Task HandleCommandAsync(SocketMessage message)
        {
            if (message is SocketUserMessage userMessage)
            {
                var context = new TupkachCommandContext(_client, userMessage, _lifetimeScope);
                var argPos  = 0;
                if (userMessage.HasStringPrefix(_configurationProvider.GetConfigurationParameter(StaticData.CommandKeywordConfigurationKey), ref argPos, StringComparison.InvariantCultureIgnoreCase))
                {
                    var result = await _service.ExecuteAsync(context, argPos);

                    if (!result.IsSuccess)
                    {
                        await context.Channel.SendMessageAsync(result.ErrorReason);
                    }
                }
            }
        }