Хочу сделать выдачу роли по нажатию на любую реакцию, подскажите как это можно сделать в discord.py (python-39)
КОД:
@Bot.event
async def on_ram_reaction_add(payload):
message_id = payload.message_id
if message_id == %%%%%%%%%%%%:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
if payload.emoji.name == ':white_check_mark:':
role = discord.utils.get(guild.roles, id='%%%%%%%%%%%%%%%%')
if role is not None:
member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
if member is not None:
await member.add_roles(role)
print("done")
else:
print("Member not found.")
else:
print("Role not found")
@Bot.event
async def on_raw_reaction_remove(payload):
message_id = payload.message_id
if message_id == %%%%%%%%%%%%%%%:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
if payload.emoji.name == ':white_check_mark:':
role = discord.utils.get(guild.roles, id=%%%%%%%%%%%%%')
if role is not None:
member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
if member is not None:
await member.add_removes(role)
print("done")
else:
print("Member not found.")
else:
print("Role not found")
ОШИБКА
Бот успешно запустился!
Ignoring exception in on_raw_reaction_remove
Traceback (most recent call last):
File "C:\Users\Макс\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Макс\DRACULA\bot.py", line 124, in on_raw_reaction_remove
guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
NameError: name 'client' is not defined