Проблема в том что добавление роли при нажатии работает:
@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
if payload.message_id == list.GAMEPOST_ID:
channel = self.client.get_channel(payload.channel_id) # получаем объект канала
guild = await self.client.fetch_guild(payload.guild_id)
emoji = str(payload.emoji)
role = discord.utils.get(guild.roles, id = list.GAMEROLES[emoji])
await payload.member.add_roles(role)
print('[ROLE] User {0.display_name} has been granted with role {1.name}'.format(payload.member, role))
А при практически идентичном коде, удаление роли вызывает ошибку:
@commands.Cog.listener()
async def on_raw_reaction_remove(self, payload):
if payload.message_id == list.GAMEPOST_ID:
channel = self.client.get_channel(payload.channel_id) # получаем объект канала
guild = await self.client.fetch_guild(payload.guild_id)
emoji = str(payload.emoji)
role = discord.utils.get(guild.roles, id = list.GAMEROLES[emoji])
await payload.member.remove_roles(role)
print('[ROLE] Role {1.name} has been remove for user {0.display_name}'.format(payload.member, role))
А вот ошибка:
Ignoring exception in on_raw_reaction_remove
Traceback (most recent call last):
File "D:\Programs\Python 3.9.2\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "d:\Warden\Project\Python\client\cogs\roles.py", line 90, in on_raw_reaction_remove
await payload.member.remove_roles(role)
AttributeError: 'NoneType' object has no attribute 'remove_roles'