Esempio n. 1
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (!(s is SocketUserMessage msg))
            {
                return;
            }

            var context = new SocketCommandContext(client, msg);

            if (context.User.IsBot)
            {
                return;
            }

            int argPos = 0;

            if (msg.HasStringPrefix(Config.bot.cmdPrefix, ref argPos, StringComparison.InvariantCultureIgnoreCase) || msg.HasMentionPrefix(client.CurrentUser, ref argPos))
            {
                var result = await service.ExecuteAsync(context, argPos, null);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    Console.WriteLine(result.ErrorReason);
                }

                await ServerGames.UserSentCommand((SocketGuildUser)context.User, (SocketTextChannel)context.Channel);
            }
        }
Esempio n. 2
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (s is not SocketUserMessage msg)
            {
                return;
            }

            var context = new SocketCommandContext(_client, msg);

            if (context.User.IsBot)
            {
                return;
            }

            var argPos = 0;

            if (msg.HasStringPrefix(Config.Bot.CmdPrefix, ref argPos, StringComparison.InvariantCultureIgnoreCase) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                var result = await _service.ExecuteAsync(context, argPos, null);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    if (result is ExecuteResult execResult)
                    {
                        Console.WriteLine(execResult.Exception);
                    }
                    Console.WriteLine(result.ErrorReason);
                }

                _ = ServerGames.UserSentCommand(context.User, context.Channel);
            }
        }