From ac265cd1fff8c04f5190f46ab55eef0bbf4577af Mon Sep 17 00:00:00 2001 From: sgoudham Date: Tue, 21 Jul 2020 23:57:36 +0100 Subject: [PATCH] Moved Directories of Cogs --- cogs/{anime => }/anime.py | 0 cogs/{fun => }/enso.py | 129 +++++++++++++++++++++++++++++++ cogs/{fun => }/fun.py | 0 cogs/{help => }/help.py | 0 cogs/{help => }/info.py | 0 cogs/{anime => }/interactive.py | 0 cogs/{modmail => }/modmail.py | 0 cogs/{anime => }/relationship.py | 0 cogs/{help => }/test.py | 0 9 files changed, 129 insertions(+) rename cogs/{anime => }/anime.py (100%) rename cogs/{fun => }/enso.py (75%) rename cogs/{fun => }/fun.py (100%) rename cogs/{help => }/help.py (100%) rename cogs/{help => }/info.py (100%) rename cogs/{anime => }/interactive.py (100%) rename cogs/{modmail => }/modmail.py (100%) rename cogs/{anime => }/relationship.py (100%) rename cogs/{help => }/test.py (100%) diff --git a/cogs/anime/anime.py b/cogs/anime.py similarity index 100% rename from cogs/anime/anime.py rename to cogs/anime.py diff --git a/cogs/fun/enso.py b/cogs/enso.py similarity index 75% rename from cogs/fun/enso.py rename to cogs/enso.py index fc7fe522..d6aadb01 100644 --- a/cogs/fun/enso.py +++ b/cogs/enso.py @@ -12,6 +12,17 @@ import settings from settings import colour_list, enso_guild_ID, enso_ensochancommands_Mention, blank_space, enso_embedmod_colours, \ enso_verification_ID +"""events = { + "🎤": 722483603409469470, # Karaoke Night + "🎧": 696753950879383605, # Enso Bros Podcast + "🎥": 722482922518609990, # Movie Night + "🎮": 722493033882452078, # Game Night + ":GameNight:": 722493033882452078, + ":EnsoBros:": 696753950879383605, + ":MovieNight:": 722482922518609990, + ":Karaoke:": 722483603409469470 +}""" + # Error handling function to make sure that the commands only work in "enso-chan-commands" def error_function(): @@ -367,6 +378,124 @@ class Enso(commands.Cog): verif = await ctx.fetch_message(728424149692842115) await verif.edit(embed=embed) + # Cog listener for enabling roles to be added to users when they react to the embedded message + @commands.Cog.listener() + async def on_raw_reaction_add(self, payload): + + # 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, self.bot.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") + + """# Make sure the reaction event doesn't count other channels + if not payload.channel_id == 722347423913213992: + return + + role = payload.member.guild.get_role(events.get(payload.emoji.name)) + await payload.member.add_roles(role) + print(f"{payload.member.name} Was Given Role {role}")""" + + # Cog listener for enabling roles to be removed from users when they unreact to the embedded messaged + @commands.Cog.listener() + async def on_raw_reaction_remove(self, payload): + + # 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, self.bot.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) + + """# Make sure the reaction event doesn't count other channels + if not payload.channel_id == 722347423913213992: + return + + guild = self.bot.get_guild(payload.guild_id) + + member = guild.get_member(payload.user_id) + role = guild.get_role(events.get(payload.emoji.name)) + await member.remove_roles(role) + print(f"{member.name} Was Removed from Role {role}")""" + + # Allowing people to get ping-able self roles + @command(name="rolemenu", hidden=True) + @is_owner() + async def role_menu(self, ctx): + # Setting the channel to " + channel = ctx.guild.get_channel(722347423913213992) + + # Set up embed to let people know what ping-able roles can be chosen + embed = Embed(title="**Role Menu: Ping-Able Roles**", + colour=Colour.orange(), + timestamp=datetime.datetime.utcnow()) + + embed.set_thumbnail(url=ctx.guild.icon_url) + embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url) + embed.set_footer(text=f"{ctx.message.author}", icon_url=ctx.author.avatar_url) + embed.add_field( + name="\u200b", + value="React to give yourself roles to be pinged for these events!", + inline=False) + embed.add_field( + name="\u200b", + value="🎥 : `Movie Nights`", + inline=False) + embed.add_field( + name="\u200b", + value="🎤 : `Karaoke Nights`", + inline=False) + embed.add_field( + name="\u200b", + value="🎧 : `Enso Bros Podcasts`", + inline=False) + embed.add_field( + name="\u200b", + value="🎮 : `Game Nights`", + inline=False) + + # Edit the Embed And Update it + message = await ctx.fetch_message(722514840559812649) + await message.edit(embed=embed) + + # Send the embed to the channel "newpeople" + # await channel.send(embed=embed) + def setup(bot): bot.add_cog(Enso(bot)) diff --git a/cogs/fun/fun.py b/cogs/fun.py similarity index 100% rename from cogs/fun/fun.py rename to cogs/fun.py diff --git a/cogs/help/help.py b/cogs/help.py similarity index 100% rename from cogs/help/help.py rename to cogs/help.py diff --git a/cogs/help/info.py b/cogs/info.py similarity index 100% rename from cogs/help/info.py rename to cogs/info.py diff --git a/cogs/anime/interactive.py b/cogs/interactive.py similarity index 100% rename from cogs/anime/interactive.py rename to cogs/interactive.py diff --git a/cogs/modmail/modmail.py b/cogs/modmail.py similarity index 100% rename from cogs/modmail/modmail.py rename to cogs/modmail.py diff --git a/cogs/anime/relationship.py b/cogs/relationship.py similarity index 100% rename from cogs/anime/relationship.py rename to cogs/relationship.py diff --git a/cogs/help/test.py b/cogs/test.py similarity index 100% rename from cogs/help/test.py rename to cogs/test.py