fix error when adding reaction in DM channel
This commit is contained in:
parent
f9c02e6c95
commit
be47cc43b0
2 changed files with 11 additions and 3 deletions
|
@ -133,7 +133,9 @@ class ConfrerieDuKassoulait(commands.Cog):
|
||||||
await payload.member.add_roles(payload.member.guild.get_role(self.messageDictAndEmojiToRoles[payload.message_id][payload.emoji.id]))
|
await payload.member.add_roles(payload.member.guild.get_role(self.messageDictAndEmojiToRoles[payload.message_id][payload.emoji.id]))
|
||||||
except:
|
except:
|
||||||
await payload.member.add_roles(payload.member.guild.get_role(self.messageDictAndEmojiToRoles[payload.message_id][str(payload.emoji)]))
|
await payload.member.add_roles(payload.member.guild.get_role(self.messageDictAndEmojiToRoles[payload.message_id][str(payload.emoji)]))
|
||||||
except KeyError:
|
except KeyError: # mauvais message ou réaction
|
||||||
|
return
|
||||||
|
except AttributeError: # reaction en DM
|
||||||
return
|
return
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
|
@ -148,3 +150,5 @@ class ConfrerieDuKassoulait(commands.Cog):
|
||||||
await member.remove_roles(guild.get_role(self.messageDictAndEmojiToRoles[payload.message_id][str(payload.emoji)]))
|
await member.remove_roles(guild.get_role(self.messageDictAndEmojiToRoles[payload.message_id][str(payload.emoji)]))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
except AttributeError: # reaction en DM
|
||||||
|
return
|
||||||
|
|
|
@ -9,8 +9,12 @@ async def listReaction(client, payload):
|
||||||
"""
|
"""
|
||||||
if payload.emoji.name in ["⬅️", "🔄", "➡️"]:
|
if payload.emoji.name in ["⬅️", "🔄", "➡️"]:
|
||||||
if payload.event_type == "REACTION_ADD":
|
if payload.event_type == "REACTION_ADD":
|
||||||
if payload.member.bot == True: # vérifie que c'est pas un bot qui a réagit
|
if payload.member: # check car pas de member en DM
|
||||||
return False, False
|
if payload.member.bot == True: # vérifie que c'est pas un bot qui a réagit
|
||||||
|
return False, False
|
||||||
|
else:
|
||||||
|
if client.get_user(payload.user_id).bot == True: # vérifie que c'est pas un bot qui a réagit
|
||||||
|
return False, False
|
||||||
channel = client.get_channel(payload.channel_id)
|
channel = client.get_channel(payload.channel_id)
|
||||||
message = await channel.fetch_message(payload.message_id)
|
message = await channel.fetch_message(payload.message_id)
|
||||||
if message.author.id != client.user.id or len(message.embeds) == 0: # vérification message du bot + au moins 1 embed
|
if message.author.id != client.user.id or len(message.embeds) == 0: # vérification message du bot + au moins 1 embed
|
||||||
|
|
Reference in a new issue