【发布时间】:2020-11-29 05:47:44
【问题描述】:
我试图在 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()
【问题讨论】:
标签: sqlite discord discord.py discord.py-rewrite