Exemplo n.º 1
0
        private async Task MessageUpdatedHandler(Cacheable <IMessage, ulong> oldMsg, SocketMessage newMsg, ISocketMessageChannel channel)
        {
            if (channel is ITextChannel txtChannel)
            {
                using var scope = _serviceProvider.CreateScope();

                if (newMsg.Type != MessageType.Default && newMsg.Type != MessageType.Reply)
                {
                    return;
                }
                if (newMsg.Author.IsBot)
                {
                    return;
                }
                if (txtChannel.Guild == null)
                {
                    return;
                }

                AutoModerator autoModerator = null;
                try
                {
                    autoModerator = await AutoModerator.CreateDefault(_client, txtChannel.Guild.Id, scope.ServiceProvider);
                }
                catch (ResourceNotFoundException)
                {
                    return;
                }
                await autoModerator.HandleAutomoderation(newMsg, true);
            }

            return;
        }
Exemplo n.º 2
0
        private async Task MessageCreatedHandler(SocketMessage message)
        {
            if (message.Channel is ITextChannel channel)
            {
                using var scope = _serviceProvider.CreateScope();

                if (message.Type != MessageType.Default && message.Type != MessageType.Reply)
                {
                    return;
                }
                if (message.Author.IsBot)
                {
                    return;
                }
                if (channel.Guild == null)
                {
                    return;
                }

                AutoModerator autoModerator = null;
                try
                {
                    autoModerator = await AutoModerator.CreateDefault(_client, channel.Guild.Id, scope.ServiceProvider);
                }
                catch (ResourceNotFoundException)
                {
                    return;
                }
                await autoModerator.HandleAutomoderation(message);
            }
        }