import discord
import asyncio
import requests
from discord import Member
from discord.utils import get
from discord.ext import commands
from config import settings
bot = commands.Bot(command_prefix = settings['prefix'])
---
@bot.command(pass_context=True)
@commands.has_role("admin")
async def addrole(ctx, role: discord.Role, member: discord.Member=None):
member = member or ctx.message.author
print(member)
print(role)
await member.add_roles(member, role)
Команда:
Выдает ошибку
Ignoring exception in command addrole:
Traceback (most recent call last):
File "C:\Users\Professional\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Overseer\bot.py", line 45, in addrole
await member.add_roles(member, role)
File "C:\Users\Professional\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\member.py", line 664, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
File "C:\Users\Professional\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\http.py", line 243, in request
raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Professional\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Professional\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Professional\AppData\Local\Programs\Python\Python37\lib\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: NotFound: 404 Not Found (error code: 10011): Unknown Role