示例#1
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (!(s is SocketUserMessage msg) || msg.Author.IsBot || msg.Channel is SocketDMChannel)
            {
                return;
            }

            var clientPrefix = false;
            var argPos       = 0;
            var context      = new CommandContextWithPrefix(_client, msg);
            var guild        = await _guild.GetGuild(context.Guild.Id);

            context.Prefix = guild.Prefix;

            await _points.GivePoints(context.User.Id, context.Guild.Id).ConfigureAwait(false);

            if (!(msg.HasStringPrefix(guild.Prefix, ref argPos) ||
                  (clientPrefix = msg.HasMentionPrefix(_client.CurrentUser, ref argPos))))
            {
                return;
            }

            await s.Channel.TriggerTypingAsync();

            var result = await _service.ExecuteAsync(context, argPos, _provider);

            if (!result.IsSuccess)
            {
                await HandleResultAsync(result, context, guild, clientPrefix);
            }
        }