|
|
@ -25,7 +25,10 @@ if __name__ == '__main__':
|
|
|
|
# Bot Status on Discord
|
|
|
|
# Bot Status on Discord
|
|
|
|
@client.event
|
|
|
|
@client.event
|
|
|
|
async def on_ready():
|
|
|
|
async def on_ready():
|
|
|
|
|
|
|
|
# Tells me that the bot is ready and logged in
|
|
|
|
print('Bot is ready.')
|
|
|
|
print('Bot is ready.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Sets the bots status on discord for everyone to view
|
|
|
|
await client.change_presence(
|
|
|
|
await client.change_presence(
|
|
|
|
activity=discord.Streaming(name="Falling in Love Again 😍 ", url="https://www.twitch.tv/goudham"))
|
|
|
|
activity=discord.Streaming(name="Falling in Love Again 😍 ", url="https://www.twitch.tv/goudham"))
|
|
|
|
|
|
|
|
|
|
|
@ -34,6 +37,7 @@ async def on_ready():
|
|
|
|
@client.command(aliases=["Ping"])
|
|
|
|
@client.command(aliases=["Ping"])
|
|
|
|
@commands.has_any_role('Hamothy', 'Servant')
|
|
|
|
@commands.has_any_role('Hamothy', 'Servant')
|
|
|
|
async def ping(ctx):
|
|
|
|
async def ping(ctx):
|
|
|
|
|
|
|
|
# Send the latency of the bot (ms)
|
|
|
|
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
|
|
|
|
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +45,7 @@ async def ping(ctx):
|
|
|
|
@client.event
|
|
|
|
@client.event
|
|
|
|
async def on_command_error(ctx, error):
|
|
|
|
async def on_command_error(ctx, error):
|
|
|
|
if isinstance(error, commands.CommandOnCooldown):
|
|
|
|
if isinstance(error, commands.CommandOnCooldown):
|
|
|
|
|
|
|
|
# Send an error message to the user telling them that the command is on cooldown
|
|
|
|
message = await ctx.send(f'That command is on cooldown. Try again in {error.retry_after:,.2f} seconds.')
|
|
|
|
message = await ctx.send(f'That command is on cooldown. Try again in {error.retry_after:,.2f} seconds.')
|
|
|
|
|
|
|
|
|
|
|
|
# Let the user read the message for 2.5 seconds
|
|
|
|
# Let the user read the message for 2.5 seconds
|
|
|
@ -53,9 +58,10 @@ async def on_command_error(ctx, error):
|
|
|
|
@client.event
|
|
|
|
@client.event
|
|
|
|
async def on_command_error(ctx, target: discord.member):
|
|
|
|
async def on_command_error(ctx, target: discord.member):
|
|
|
|
if isinstance(target, commands.MissingRequiredArgument):
|
|
|
|
if isinstance(target, commands.MissingRequiredArgument):
|
|
|
|
|
|
|
|
# Send an error message to the user saying that an argument is missing
|
|
|
|
message = await ctx.send("Uh oh! Couldn't find anyone to mention! Try again!")
|
|
|
|
message = await ctx.send("Uh oh! Couldn't find anyone to mention! Try again!")
|
|
|
|
|
|
|
|
|
|
|
|
# Let the user read the message for 2.5 seconds
|
|
|
|
# Let the user read the message for 1.5 seconds
|
|
|
|
await asyncio.sleep(1.5)
|
|
|
|
await asyncio.sleep(1.5)
|
|
|
|
# Delete the message
|
|
|
|
# Delete the message
|
|
|
|
await message.delete()
|
|
|
|
await message.delete()
|
|
|
@ -65,9 +71,10 @@ async def on_command_error(ctx, target: discord.member):
|
|
|
|
@client.event
|
|
|
|
@client.event
|
|
|
|
async def on_command_error(ctx, error):
|
|
|
|
async def on_command_error(ctx, error):
|
|
|
|
if isinstance(error, commands.CheckFailure):
|
|
|
|
if isinstance(error, commands.CheckFailure):
|
|
|
|
|
|
|
|
# Send an error message to the user saying that they don't have persmission to use this command
|
|
|
|
message = await ctx.send("Uh oh! You don't have permission to use this command!")
|
|
|
|
message = await ctx.send("Uh oh! You don't have permission to use this command!")
|
|
|
|
|
|
|
|
|
|
|
|
# Let the user read the message for 2.5 seconds
|
|
|
|
# Let the user read the message for 1.5 seconds
|
|
|
|
await asyncio.sleep(1.5)
|
|
|
|
await asyncio.sleep(1.5)
|
|
|
|
# Delete the message
|
|
|
|
# Delete the message
|
|
|
|
await message.delete()
|
|
|
|
await message.delete()
|
|
|
@ -83,6 +90,8 @@ async def on_member_join(member):
|
|
|
|
|
|
|
|
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set up embed for the #newpeople channel
|
|
|
|
embed = discord.Embed(title="\n**Welcome To Ensō!**",
|
|
|
|
embed = discord.Embed(title="\n**Welcome To Ensō!**",
|
|
|
|
colour=discord.Colour(0x30e419))
|
|
|
|
colour=discord.Colour(0x30e419))
|
|
|
|
|
|
|
|
|
|
|
@ -105,26 +114,35 @@ async def on_member_join(member):
|
|
|
|
value=f"Last but not least, feel free to go into <#669775971297132556> to introduce yourself!",
|
|
|
|
value=f"Last but not least, feel free to go into <#669775971297132556> to introduce yourself!",
|
|
|
|
inline=False)
|
|
|
|
inline=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Send embed to #newpeople
|
|
|
|
await new_people.send(embed=embed)
|
|
|
|
await new_people.send(embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set hamothyID equal to my id in discord
|
|
|
|
hamothyID = '<@&715412394968350756>'
|
|
|
|
hamothyID = '<@&715412394968350756>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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"Welcome to the server! {member.mention} I hope you enjoy your stay here <a:huh:676195228872474643> <a:huh:676195228872474643> " \
|
|
|
|
f"\nPlease go into <#722347423913213992> to choose some ping-able roles for events! " \
|
|
|
|
f"\nPlease go into <#722347423913213992> to choose some ping-able roles for events! " \
|
|
|
|
f"\nPlease ping {hamothyID} for any questions about the server and of course, the other staff members!"
|
|
|
|
f"\nPlease ping {hamothyID} for any questions about the server and of course, the other staff members!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Send welcome message to #general
|
|
|
|
await general.send(general_welcome)
|
|
|
|
await general.send(general_welcome)
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
print(e)
|
|
|
|
except Exception as ex:
|
|
|
|
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Allowing people to get ping-able self roles
|
|
|
|
# Allowing people to get ping-able self roles
|
|
|
|
@client.command(name="rolemenu")
|
|
|
|
@client.command(name="rolemenu")
|
|
|
|
@commands.has_any_role('Hamothy')
|
|
|
|
@commands.has_any_role('Hamothy')
|
|
|
|
async def role_menu(ctx):
|
|
|
|
async def role_menu(ctx):
|
|
|
|
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get the channel id of #self-roles
|
|
|
|
channel = client.get_channel(722347423913213992)
|
|
|
|
channel = client.get_channel(722347423913213992)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set up embed to let people know what ping-able roles can be chosen
|
|
|
|
embed = discord.Embed(title="**Role Menu: Ping-Able Roles**", colour=discord.Colour.orange())
|
|
|
|
embed = discord.Embed(title="**Role Menu: Ping-Able Roles**", colour=discord.Colour.orange())
|
|
|
|
|
|
|
|
|
|
|
|
embed.timestamp = datetime.datetime.utcnow()
|
|
|
|
embed.timestamp = datetime.datetime.utcnow()
|
|
|
@ -156,7 +174,9 @@ async def role_menu(ctx):
|
|
|
|
value="<:GameNights:722502073769525268> : `Game Nights`",
|
|
|
|
value="<:GameNights:722502073769525268> : `Game Nights`",
|
|
|
|
inline=False)
|
|
|
|
inline=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Send embed to #self-roles
|
|
|
|
await channel.send(embed=embed)
|
|
|
|
await channel.send(embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
|
@ -164,21 +184,35 @@ async def role_menu(ctx):
|
|
|
|
# Bot event for enabling roles to be added to users when they react to the embedded message
|
|
|
|
# Bot event for enabling roles to be added to users when they react to the embedded message
|
|
|
|
@client.event
|
|
|
|
@client.event
|
|
|
|
async def on_raw_reaction_add(payload):
|
|
|
|
async def on_raw_reaction_add(payload):
|
|
|
|
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If the message id equals the self roles message
|
|
|
|
if payload.message_id == 722514840559812649:
|
|
|
|
if payload.message_id == 722514840559812649:
|
|
|
|
|
|
|
|
# Print out the emoji name
|
|
|
|
print(payload.emoji.name)
|
|
|
|
print(payload.emoji.name)
|
|
|
|
|
|
|
|
|
|
|
|
# Find a role corresponding to the Emoji name.
|
|
|
|
# Find a role corresponding to the Emoji name.
|
|
|
|
guild_id = payload.guild_id
|
|
|
|
guild_id = payload.guild_id
|
|
|
|
guild = discord.utils.find(lambda g: g.id == guild_id, client.guilds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
role = discord.utils.find(lambda r: r.name == payload.emoji.name, guild.roles)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if the role does exist
|
|
|
|
if role is not None:
|
|
|
|
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.name + " was found!")
|
|
|
|
print(role.id)
|
|
|
|
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)
|
|
|
|
member = discord.utils.find(lambda m: m.id == payload.user_id, guild.members)
|
|
|
|
|
|
|
|
# Add the role to the member
|
|
|
|
await member.add_roles(role)
|
|
|
|
await member.add_roles(role)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Print to me that the role has been added
|
|
|
|
print("done")
|
|
|
|
print("done")
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
|
@ -186,19 +220,31 @@ async def on_raw_reaction_add(payload):
|
|
|
|
# Bot event for enabling roles to be removed from users when they unreact to the embedded messaged
|
|
|
|
# Bot event for enabling roles to be removed from users when they unreact to the embedded messaged
|
|
|
|
@client.event
|
|
|
|
@client.event
|
|
|
|
async def on_raw_reaction_remove(payload):
|
|
|
|
async def on_raw_reaction_remove(payload):
|
|
|
|
|
|
|
|
# Surround with try/except to catch any exceptions that may occur
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If the message id equals the self roles message
|
|
|
|
if payload.message_id == 722514840559812649:
|
|
|
|
if payload.message_id == 722514840559812649:
|
|
|
|
|
|
|
|
# Print out the emoji name
|
|
|
|
print(payload.emoji.name)
|
|
|
|
print(payload.emoji.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get the server id
|
|
|
|
guild_id = payload.guild_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)
|
|
|
|
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)
|
|
|
|
role = discord.utils.find(lambda r: r.name == payload.emoji.name, guild.roles)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if the role does exist
|
|
|
|
if role is not None:
|
|
|
|
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)
|
|
|
|
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:
|
|
|
|
|
|
|
|
print(e)
|
|
|
|
except Exception as ex:
|
|
|
|
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Run the bot, allowing to come online
|
|
|
|
# Run the bot, allowing to come online
|
|
|
|