So far I have a message that a new user can react to in a certain channel in discord that will assign them a role based on the reaction they choose (this part is working). I also want the role to be removed from the user if they remove their reaction to that message (this is what's not working). I get an error message saying: line 23, in on_raw_reaction_remove role = discord.utils.get(payload.member.guild.roles, name='War Thunder') AttributeError: 'NoneType' object has no attribute 'guild'
@client.event
# this works to assign a role
async def on_raw_reaction_add(payload):
# channel and message IDs should be integer:
if payload.channel_id == 700895165665247325 and payload.message_id == 756577133165543555:
if str(payload.emoji) == "<:WarThunder:745425772944162907>":
role = discord.utils.get(payload.member.guild.roles, name='War Thunder')
await payload.member.add_roles(role)
# this doesn't work in removing the role
async def on_raw_reaction_remove(self, payload):
if payload.channel_id == 700895165665247325 and payload.message_id == 756577133165543555:
if str(payload.emoji) != "<:WarThunder:745425772944162907>":
role = discord.utils.get(payload.member.guild.roles, name='War Thunder')
await payload.member.remove_roles(role)