Я сделал команду для выдачи роли. Роль бот должен доставать из БД. Но у меня не работает.
Вот ошибка:
Ignoring exception in command test:
Traceback (most recent call last):
File "/home/runner/manul/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 86, in test
await ctx.author.add_roles(role)
File "/home/runner/manul/venv/lib/python3.8/site-packages/discord/member.py", line 777, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/manul/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/manul/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/runner/manul/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
Код команды:
@bot.command()
async def test(ctx):
guild = ctx.guild
role = discord.utils.get(guild.roles, id=cursor.execute(f"SELECT verify_role FROM role WHERE id = {ctx.author.guild.id}").fetchone())
await ctx.author.add_roles(role)
await ctx.message.add_reaction('✅')