Exemple #1
0
        private Task ClientOnMessageUpdated(Cacheable <IMessage, ulong> arg1, SocketMessage arg2, ISocketMessageChannel arg3)
        {
            if (!(arg2 is SocketUserMessage message))
            {
                return(Task.CompletedTask);
            }
            if (message.Source != MessageSource.User)
            {
                return(Task.CompletedTask);
            }

            if (!Config.Ready)
            {
                return(Task.CompletedTask);
            }

            if (Garden.TreeState.UsersConnecting.Contains(arg2.Author.Id))
            {
                Garden.Tree.OnUserMessageAsync(arg2, arg2.Channel is SocketDMChannel).Forget();
                return(Task.CompletedTask);
            }

            try
            {
                ChatFilter.OnChatAsync(arg2).Forget();
                Garden.LetterMatchGame.OnTextEdit(arg2).Forget();
            }
            catch
            {
            }
            return(Task.CompletedTask);
        }
Exemple #2
0
        private Task MessageReceived(SocketMessage rawMessage)
        {
            Task.Run(async() =>
            {
                // Ignore system messages and messages from bots
                if (!(rawMessage is SocketUserMessage message))
                {
                    return;
                }
                if (message.Source != MessageSource.User)
                {
                    return;
                }

                if (!Config.Ready)
                {
                    return;
                }

                if (Garden.TreeState.UsersConnecting.Contains(rawMessage.Author.Id))
                {
                    Garden.Tree.OnUserMessageAsync(rawMessage, rawMessage.Channel is SocketDMChannel).Forget();
                    return;
                }

                if (rawMessage.Channel.Id == 725059963566817372)
                {
                    await Garden.LetterMatchGame.OnText(rawMessage);
                    return;
                }

                int argPos = 0;
                if (await ChatFilter.OnChatAsync(rawMessage))
                {
                    if (message.HasStringPrefix(Config.Prefix, ref argPos))
                    {
                        var context = new SocketCommandContext(_discord, message);

                        var result = await _commands.ExecuteAsync(context, argPos, _provider).ConfigureAwait(false);

                        if (result.Error.HasValue &&
                            result.Error.Value != CommandError.UnknownCommand)
                        {
                            await context.Channel.SendMessageAsync(result.ToString()).ConfigureAwait(false);
                        }
                    }
                }
            });
            return(Task.CompletedTask);
        }