Removing the reaction roles

pull/4/head
sgoudham 5 years ago
parent 65cb86fedd
commit 83795fb249

@ -138,72 +138,6 @@ async def role_menu(ctx):
print(ex)
# Bot event for enabling roles to be added to users when they react to the embedded message
@client.event
async def on_raw_reaction_add(payload):
# Surround with try/except to catch any exceptions that may occur
try:
# If the message id equals the self roles message
if payload.message_id == 722514840559812649:
# Print out the emoji name
print(payload.emoji.name)
# Find a role corresponding to the Emoji name.
guild_id = payload.guild_id
# Find the guild Enso and find the role of the emoji that has been reacted to
guild = discord.utils.find(lambda g: g.id == guild_id, client.guilds)
role = discord.utils.find(lambda r: r.name == payload.emoji.name, guild.roles)
# if the role does exist
if role is not None:
# Print to me that the role was found and display the id of the role
print(role.name + " was found!")
print(role.id)
# Find the member who had reacted to the emoji
member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members)
# Add the role to the member
await member.add_roles(role)
# Print to me that the role has been added
print("done")
except Exception as ex:
print(ex)
# Bot event for enabling roles to be removed from users when they unreact to the embedded messaged
@client.event
async def on_raw_reaction_remove(payload):
# Surround with try/except to catch any exceptions that may occur
try:
# If the message id equals the self roles message
if payload.message_id == 722514840559812649:
# Print out the emoji name
print(payload.emoji.name)
# Get the server id
guild_id = payload.guild_id
# Find the guild Enso and find the role of the emoji that has been unreacted to
guild = discord.utils.find(lambda g: g.id == guild_id, client.guilds)
role = discord.utils.find(lambda r: r.name == payload.emoji.name, guild.roles)
# if the role does exist
if role is not None:
# Find the member that has the role which the emoji is connected to
member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members)
# Remove the role from the member
await member.remove_roles(role)
except Exception as ex:
print(ex)
# ~marry command allows the bot to wed two young lovers together
@client.command(name="marry", aliases=["Marry"])
async def marry(ctx, member: Member):

Loading…
Cancel
Save