本文介绍了Discord.py SQLite3 禁用词系统 - 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我尝试使用 sqlite3 制作一个禁用词系统,但我遇到了一个问题,它根本没有错误,也不起作用
So, i tried making a banned word system using sqlite3, but i've ran into a issue and it doesn't error at all nor does it work
我的代码:(是的,我导入了 sqlite3)&格式是正确的,它只是它自己的代码
My code: ( yes i imported sqlite3 ) & the formatting is correct, its just the code it self
@commands.Cog.listener()
async def on_message(self, member):
db = sqlite3.connect('.//SQL//bannedwords.sqlite')
cursor = db.cursor()
cursor.execute(f'SELECT msg FROM bannedwords WHERE guild_id = {message.guild.id}')
result = cursor.fetchone()
if result is None:
return
else:
cursor.execute(f"SELECT msg FROM main WHERE guild_id = {member.guild.id}")
result = cursor.fetchone()
await message.author.delete()
embed=discord.Embed(title="Blacklisted Word", description="Test")
await message.send(embed=embed, delete_after=7.0)
@commands.group(invoke_without_commands=True)
async def add(self, ctx):
return
@add.command()
async def word(self, ctx, channel:discord.TextChannel):
if ctx.message.author.guild_permissions.administrator:
db = sqlite3.connect('.//SQL//bannedwords.sqlite')
cursor = db.cursor()
cursor.execute(f'SELECT msg FROM bannedwords WHERE guild_id = {ctx.guild.id}')
result = cursor.fetchone()
if result is None:
sql = ("INSERT INTO bannedwords(guild_id, msg) VALUES(?,?)")
val = (ctx.guild.id, msg)
await ctx.send(f"h")
elif result is not None:
sql = ("UPDATE bannedwords SET msg = ? WHERE guild_id = ?")
val = (msg, ctx.guild.id)
await ctx.send(f"added")
cursor.execute(sql, val)
db.commit()
cursor.close()
db.close()
我知道我放置了一个文本通道,但我认为这不是唯一的问题 - 或者我不太确定我应该用什么替换它以检测 msg 列中的消息
I am aware that i put a text channel, but i don't think thats the only issue - or rather i'm not too sure on what do i replace it with for it to detect messages that are in the msg column
推荐答案
使用 message.channel.send
而不是 message.send
.
这篇关于Discord.py SQLite3 禁用词系统 - 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!