SHARE
TWEET

Role Reaction

dbloc Oct 20th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import discord
  2.  
  3. client = discord.Client()
  4.  
  5. @client.event
  6. async def on_ready():
  7.     print("Bot is logged in.")
  8.  
  9. @client.event
  10. async def on_raw_reaction_add(payload):
  11.     message_id = payload.message_id
  12.     if message_id == 635397427070763037:
  13.         guild_id = payload.guild.id
  14.         guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
  15.        
  16.         if payload.emoji.name == '✅':
  17.             role = discord.utils.get(guild.roles, name='Life of the Party')
  18.         else:
  19.             role = discord.utils.get(guild.roles, name=payload.emoji.name)
  20.  
  21.         if role is not None:
  22.             member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
  23.             if member is not None:
  24.                 await member.add_roles(role)
  25.                 print("done")
  26.             else:
  27.                 print("Member not found")
  28.         else:
  29.             print("Role not Found")
  30.  
  31. @client.event
  32. async def on_raw_reaction_remove(payload):
  33.     pass
  34. client.run('TOKEN')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top