我试图在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()
答案 0 :(得分:1)
AttributeError: 'WebElement' object has no attribute 'find_element_class_name'
将遍历输入字符串中的每个字符而不是每个单词,因此它永远不会与您的任何不良单词匹配。相反,通过用if any(b in bword for b in message.content.lower())
拆分各个单词来进行迭代。