use role id instead of role names
This commit is contained in:
parent
b413cecd97
commit
65e0e25e32
1 changed files with 7 additions and 9 deletions
|
@ -16,11 +16,11 @@ class ConfrerieDuKassoulait(commands.Cog):
|
|||
self.client = client
|
||||
self.role_message_id = 882785207235788800 # ID of the message that can be reacted to to add/remove a role.
|
||||
self.emoji_to_role = {
|
||||
882783004706095194: "L1", # elephant
|
||||
882783004697714789: "L2", # gorilla
|
||||
882783004416675881: "L3", # cat
|
||||
882783005108744202: "visiteurs ✨", # rabbit
|
||||
882783004911624212: "Alumni" # dog
|
||||
882783004706095194: 882616261626970112, # elephant - l1
|
||||
882783004697714789: 882616188830629998, # gorilla - l2
|
||||
882783004416675881: 882616082022670387, # cat - - l3
|
||||
882783005108744202: 882616475918147654, # rabbit - visiteurs
|
||||
882783004911624212: 882616714133635093 # dog - alumni
|
||||
}
|
||||
|
||||
@commands.Cog.listener()
|
||||
|
@ -127,8 +127,7 @@ class ConfrerieDuKassoulait(commands.Cog):
|
|||
self.emoji_to_role[payload.emoji.id]
|
||||
except KeyError:
|
||||
return
|
||||
role = discord.utils.get(payload.member.guild.roles, name = self.emoji_to_role[payload.emoji.id])
|
||||
await payload.member.add_roles(role)
|
||||
await payload.member.add_roles(self.client.get_role(self.emoji_to_role[payload.emoji.id]))
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_raw_reaction_remove(self, payload):
|
||||
|
@ -140,5 +139,4 @@ class ConfrerieDuKassoulait(commands.Cog):
|
|||
return
|
||||
guild = discord.utils.find(lambda g: g.id == payload.guild_id, self.client.guilds)
|
||||
member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members)
|
||||
role = discord.utils.get(guild.roles, name = self.emoji_to_role[payload.emoji.id])
|
||||
await member.remove_roles(role)
|
||||
await member.remove_roles(self.client.get_role(self.emoji_to_role[payload.emoji.id]))
|
||||
|
|
Reference in a new issue