示例#1
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            var message = arg as SocketUserMessage;

            if (message is null || message.Author.IsBot)
            {
                return;
            }

            DiscordServer server = discordServers.Find(x => x.Guild.GetChannel(message.Channel.Id) == message.Channel);
            ServerUser    user   = server.Users.Find(x => x.userID == message.Author.Id);
            await Swearing.CheckText(user, server, message);

            int argPos = 0;

            if (message.HasStringPrefix(botPrefix.ToString(), ref argPos))
            {
                var context = new SocketCommandContext(_client, message);

                var result = await _commands.ExecuteAsync(context, argPos, _services);

                if (!result.IsSuccess)
                {
                    if (result.ErrorReason != "Unknown command.")
                    {
                        Console.WriteLine(result.ErrorReason);
                        await message.Channel.SendMessageAsync(result.ErrorReason);
                    }
                }
            }
            else if (message.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                Modules.Talk.TalkWithBot(message);
            }

            AddPoints(message, server, user);
            await Swearing.SwearChecker(message, server, user);
        }
示例#2
0
 private async Task OnMessageUpdated(Cacheable <IMessage, ulong> arg1, SocketMessage arg2, ISocketMessageChannel arg3)
 {
     DiscordServer server = discordServers.Find(x => x.Guild.GetChannel(arg2.Channel.Id) == arg2.Channel);
     ServerUser    user   = server.Users.Find(x => x.userID == arg2.Author.Id);
     await Swearing.SwearChecker((SocketUserMessage)arg2, server, user);
 }