我正在尝试使用 sqllite 将用户的 id 上传到数据库,但是每当我运行代码并执行命令时,它都会显示此错误
discord.ext.commands.errors.CommandInvokeError:命令引发异常:NameError:名称“main”未定义
async def add(self, ctx, user:discord.User):
if ctx.message.author.guild_permissions.manage_messages:
db = sqlite3.connect('main.sqlite')
cursor = main.cursor()
cursor.execute(f"SELECT Players FROM main")
result = cursor.fetchall()
if result != user.id:
sql = ("INSERT INTO main(Players) VALUES(?)")
val = (user.id)
await ctx.send(f"<@!{user.id}> has been added")
else:
await ctx.send(f"<@{user.id}> is already in teh database")
cursor.execute(sql,val)
db.commit()
cursor.close()
db.close()