Sqlite 机器人在说了一句坏话后没有警告我

Sqlite 机器人在说了一句坏话后没有警告我,sqlite,discord,discord.py,discord.py-rewrite,Sqlite,Discord,Discord.py,Discord.py Rewrite,我试图使用discord.py上的sqlite3制作一个坏词过滤器,它不知怎么地没有向我发送任何东西,尽管我对数据库中列出的词发誓 @commands.Cog.listener() async def on_message(self, message): if not message.author.bot: db = sqlite3.connect('main.db') cursor = db.cursor()

我试图使用discord.py上的sqlite3制作一个坏词过滤器,它不知怎么地没有向我发送任何东西,尽管我对数据库中列出的词发誓

    @commands.Cog.listener()
    async def on_message(self, message):
        if not message.author.bot:
            db = sqlite3.connect('main.db')
            cursor = db.cursor()
            cursor.execute(f"SELECT text FROM badwords WHERE guild_id = {message.guild.id}")
            result = cursor.fetchall()
            if result is None:
                return
            if result is not None:
                bword = [x[0] for x in result]
                if any(b in bword for b in message.content.lower()):
                    await message.channel.send("plz no swear my bot is noob")
                cursor.close()
                db.close()
如果message.content.lower中b的bword中的anyb将迭代输入字符串中的每个字符,而不是每个单词,那么它将永远不会与任何坏单词匹配。相反,通过使用message.content.lower.split拆分单独的单词来迭代这些单词