Как сделать считывание и проверку на наличие определенной роли участника сервера?
Я уже написал код который должен это делать но выходит ошибка.
Код:
@bot.command()
async def reserv(ctx, comm:int):
vip=False
member = ctx.author
role = member.roles
if "1143125771603419217" in role:
vip=True
if vip == False:
cena = int(comm * 15)
em = discord.Embed(title="**Заказ:**", description=f"**Отлично! К оплате {cena} ₽**"
+ "\n\n**Способы оплаты: **"
"\n**Сбер: 2202 2023 2127
2225**"
"\n*Вскоре появятся новые
способы.*"
"\n\n**После оплаты напишите
владельцу с
доказательствами.**
*creeper_kriper*",
color=0x1f8b4c)
await ctx.author.send(embed=em)
if vip == True:
cena = int(comm * 15)
cena = cena/100*90
em = discord.Embed(title="**Заказ:**", description=f"**Отлично! К оплате {cena} ₽**"
+ "\n\n**Способы оплаты: **"
"\n**Сбер: **"
"\n*Вскоре появятся новые
способы.*"
"\n\n**После оплаты напишите
владельцу с
доказательствами.**
*creeper_kriper*",
color=0x1f8b4c)
await ctx.author.send(embed=em)
Ошибка:
[2023-08-22 08:24:56] [ERROR ] discord.ext.commands.bot: Ignoring exception in command reserv
Traceback (most recent call last):
File "C:\Users\matve\Desktop\CreeperBot 1.0\lib\site-packages\discord\ext\commands\core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\matve\Desktop\CreeperBot 1.0\main.py", line 37, in reserv
role = member.roles
AttributeError: 'User' object has no attribute 'roles'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\matve\Desktop\CreeperBot 1.0\lib\site-packages\discord\ext\commands\bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\matve\Desktop\CreeperBot 1.0\lib\site-packages\discord\ext\commands\core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\matve\Desktop\CreeperBot 1.0\lib\site-packages\discord\ext\commands\core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'User' object has no attribute 'roles'
Источник: Stack Overflow на русском