@ -25,21 +25,21 @@ from discord import Embed
from discord . ext import commands
from discord . ext import commands
from discord . ext . commands import cooldown , BucketType , command , is_owner , bot_has_permissions , Cog
from discord . ext . commands import cooldown , BucketType , command , is_owner , bot_has_permissions , Cog
""" events = {
events = {
" ๐ค " : 722483603409469470 , # Karaoke Night
" ๐ค " : 722483603409469470 , # Karaoke Night
" ๐ง " : 696753950879383605 , # Enso Bros Podcast
" ๐ง " : 696753950879383605 , # Enso Bros Podcast
" ๐ฅ " : 722482922518609990 , # Movie Night
" ๐ฅ " : 722482922518609990 , # Movie Night
" ๐ฎ " : 722493033882452078 , # Game Night
" ๐ฎ " : 722493033882452078 , # Game Night
" <:xoxo:743564377864536204> " : 744356592186687521 ,
" โ " : 744356592186687521 , # Dead Chat
" ๐ค " : 747156232330281141 , # Welcomers
" ๐ " : 747307872022429808 , # Contests
" :GameNight: " : 722493033882452078 ,
" :GameNight: " : 722493033882452078 ,
" :EnsoBros: " : 696753950879383605 ,
" :EnsoBros: " : 696753950879383605 ,
" :MovieNight: " : 722482922518609990 ,
" :MovieNight: " : 722482922518609990 ,
" :Karaoke: " : 722483603409469470
" :Karaoke: " : 722483603409469470
}
}
"""
# Error handling function to make sure that the commands only work in "enso-chan-commands"
def error_function ( self ) :
def error_function ( self ) :
""" Make sure that commands only work in " enso-chan-commands " in the server """
""" Make sure that commands only work in " enso-chan-commands " in the server """
@ -53,8 +53,9 @@ def helpDm(self):
f " \n Please ping my owner { self . bot . hammy_role_ID } for any issues/questions you have! "
f " \n Please ping my owner { self . bot . hammy_role_ID } for any issues/questions you have! "
# Method to retrieve information about the user and the guild
def get_user_info ( ctx ) :
def get_user_info ( ctx ) :
""" Get user information """
# Allowing the bot to dm the user
# Allowing the bot to dm the user
author = ctx . author
author = ctx . author
@ -66,8 +67,9 @@ def get_user_info(ctx):
return author , guild_icon , enso_icon , enso_name
return author , guild_icon , enso_icon , enso_name
# Gets the member and user avatar
def getMember ( ctx ) :
def getMember ( ctx ) :
""" Get member and avtar """
# Set member as the author
# Set member as the author
member = ctx . message . author
member = ctx . message . author
# Get the member avatar
# Get the member avatar
@ -76,8 +78,9 @@ def getMember(ctx):
return member , userAvatar
return member , userAvatar
# Function to display all the images requested of the people
def displayServerImage ( array , ctx , name ) :
def displayServerImage ( array , ctx , name ) :
""" Return embed of server member requested """
# Get the member and the userAvatar
# Get the member and the userAvatar
member , userAvatar = getMember ( ctx )
member , userAvatar = getMember ( ctx )
@ -373,89 +376,50 @@ class Enso(Cog):
await member . remove_roles ( not_verified )
await member . remove_roles ( not_verified )
await member . add_roles ( lucid )
await member . add_roles ( lucid )
# Set hamothyID equal to my id in discord
# Get the welcomers role and ping them
hamothyID = ' <@&715412394968350756> '
welcomers = discord . utils . get ( guild . roles , name = " Welcome " )
# Get my own role
hammy_role = " <@&715412394968350756> "
# Set the channel id to "general"
# Set the channel id to "general"
general = guild . get_channel ( 663651584399507481 )
general = guild . get_channel ( 663651584399507481 )
# String for welcoming people in the #general channel
# String for welcoming people in the #general channel
general_welcome = f " Welcome to the server! { member . mention } I hope you enjoy your stay here <a:huh:676195228872474643> <a:huh:676195228872474643> " \
general_welcome = f " { welcomers . mention } to the server! { member . mention } I hope you enjoy your stay here <a:huh:676195228872474643> <a:huh:676195228872474643> " \
f " \n Please go into <#722347423913213992> to choose some ping-able roles for events! " \
f " \n Please go into <#722347423913213992> to choose some ping-able roles for events! " \
f " \n Please ping { ham othyID } for any questions about the server and of course, the other staff members! "
f " \n Please ping { ham my_role } for any questions about the server and of course, the other staff members! "
# Send welcome message to #general
# Send welcome message to #general
await general . send ( general_welcome )
await general . send ( general_welcome )
# If the message id equals the self roles message
# Make sure the reaction event doesn't count other channels
if payload . message_id == 722514840559812649 :
if payload . channel_id == 722347423913213992 and not payload . member . bot :
role = payload . member . guild . get_role ( events . get ( payload . emoji . name ) )
# Print out the emoji name
try :
print ( payload . emoji . name )
await payload . member . add_roles ( role )
except Exception as e :
# Find a role corresponding to the Emoji name.
print ( f " Uh Oh Role { role } Couldn ' t Be Added To { member } " , e )
guild_id = payload . guild_id
else :
print ( f " { payload . member . name } Was Given Role { role } " )
# 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 :
# 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 payload . channel_id == 722347423913213992 :
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
# Cog listener for enabling roles to be removed from users when they unreact to the embedded messaged
@Cog.listener ( )
@Cog.listener ( )
async def on_raw_reaction_remove ( self , payload ) :
async def on_raw_reaction_remove ( self , payload ) :
# If the message id equals the self roles message
# Make sure the reaction event doesn't count other channels
if payload . message_id == 722514840559812649 :
if payload . channel_id == 722347423913213992 :
guild = self . bot . get_guild ( payload . guild_id )
# 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
member = guild . get_member ( payload . user_id )
guild = discord . utils . find ( lambda g : g . id == guild_id , self . bot . guilds )
role = guild . get_role ( events . get ( payload . emoji . name ) )
role = discord . utils . find ( lambda r : r . name == payload . emoji . name , guild . roles )
try :
# if the role does exist
if role :
# 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 )
await member . remove_roles ( role )
except Exception as e :
""" # Make sure the reaction event doesn ' t count other channels
print ( f " Uh Oh Role { role } Couldn ' t Be Removed From { member } " , e )
if payload . channel_id == 722347423913213992 :
else :
guild = self . bot . get_guild ( payload . guild_id )
print ( f " { member . name } Was Removed from Role { role } " )
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
# Allowing people to get ping-able self roles
@command ( name = " rolemenu " , hidden = True )
@command ( name = " rolemenuu " , hidden = True )
@is_owner ( )
@is_owner ( )
async def role_menu ( self , ctx ) :
async def role_menu ( self , ctx ) :
# Setting the channel to "
# Setting the channel to "
@ -470,17 +434,24 @@ class Enso(Cog):
" \n \n ๐ฎ : **Game Nights** | React to be pinged for game nights! "
" \n \n ๐ฎ : **Game Nights** | React to be pinged for game nights! "
# Set up embed to let people know what ping-able roles can be chosen
# Set up embed to let people know what ping-able roles can be chosen
embed = Embed ( title = " **Role Menu: Ping-Able Roles** " ,
embed = Embed ( title = " **Ping-Able Roles** " ,
colour = Colour . orange ( ) ,
description = f " React to give yourself roles to be pinged for these events! { desc } " ,
colour = self . bot . admin_colour ,
timestamp = datetime . datetime . utcnow ( ) )
timestamp = datetime . datetime . utcnow ( ) )
embed . set_thumbnail ( url = ctx . guild . icon_url )
embed . set_thumbnail ( url = ctx . guild . icon_url )
# Edit the Embed And Update it
# Edit the Embed And Update it
message = await ctx . fetch_message ( 722514840559812649 )
# message = await ctx.fetch_message(722514840559812649)
await message . edit ( embed = embed )
# await message.edit(embed=embed)
# Send the embed to the channel "newpeople"
# Send the embed to the channel "self-roles"
# await channel.send(embed=embed)
msg = await channel . send ( embed = embed )
await msg . add_reaction ( " ๐ค " )
await msg . add_reaction ( " โ " )
await msg . add_reaction ( " ๐ " )
await msg . add_reaction ( " ๐ฅ " )
await msg . add_reaction ( " ๐ค " )
await msg . add_reaction ( " ๐ง " )
await msg . add_reaction ( " ๐ฎ " )
def setup ( bot ) :
def setup ( bot ) :