使用python脚本的sqlite中的数据库有问题

gijlo24d  于 2021-08-01  发布在  Java
关注(0)|答案(0)|浏览(152)

我有个问题。我正在尝试编写一个命令,它将生成一个用户配置文件,但是当我使用此命令时,我的discord bot(python语言)发送一个错误:

Ignoring exception in command utworzprof:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
    ret = await coro(*args,**kwargs)
  File "C:\Users\user\Desktop\hbot\arr.py", line 65, in utworzprof
    await ctx.author.add_roles(role)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\member.py", line 641, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\http.py", line 221, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
    await injected(*ctx.args,**ctx.kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50001): Missing Access

我的代码:

@bot.command()
async def utworzprof(ctx):
    async with aiosqlite.connect("databaza.db") as db:

        user = ctx.message.author.name
        role = discord.utils.find(lambda r: r.name == 'Zarabiacz', ctx.message.guild.roles)        
        if role in ctx.author.roles:
            await ctx.send(f"{user} masz już utworzony profil.")
        else:
            member = str(ctx.message.author)
            member_id = ctx.message.author.id
            await db.execute("INSERT OR IGNORE INTO ekonomia (ID, User, NinjaGold) VALUES (?, ?, 0)", (member_id, member))
            await ctx.author.add_roles(role)
            await ctx.send("Utworzono profil!")
            await db.commit()
            await db.close()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题