Нашел решение, но теперь бот присылает сообщение 4 раза.
import disnake
import os
from disnake.ext import commands
from pymongo import MongoClient
import string
cluster = MongoClient("mongodb://####")
db = cluster["#####"]
collection = db["####"]
coll2 = db["####"]
class Moderator(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message):
data = collection.find_one({
"guild_id" : message.guild.id
})
enabled = data['enabled']
plugin = coll2.find_one({
"guild_id" : message.guild.id
})
bad_words = plugin['ban_words']
ban_words = []
for word in bad_words:
word = bad_words.split(",")
ban_words.extend(word)
msg = message.content
if '####' in enabled:
for ban_word in bad_words:
if ban_words in msg:
print(ban_words)
await message.channel.send("ай-ай!")
def setup(bot: commands.Bot):
bot.add_cog(Moderator(bot))