Adding hugging command

pull/4/head
sgoudham 4 years ago
parent ba1668fb63
commit 5bf3e7e36b

@ -329,6 +329,49 @@ class Interactive(commands.Cog):
except FileNotFoundError as e:
print(e)
@command(name="hug", aliases=["Hug"])
@cooldown(1, 1, BucketType.user)
async def hug(self, ctx, target: Member):
"""Allows users to hug a person in the server"""
# Surround with try/except to catch any exceptions that may occur
try:
# If the channel that the command has been sent is in the list of accepted channels
if str(ctx.channel) in settings.channels:
# Open the file containing the hug gifs
with open('images/FunCommands/hugging.txt') as file:
# Store content of the file in hugging_array
hugging_array = file.readlines()
# Get the member and the userAvatar
member, userAvatar = getMember(ctx)
# Set up the embed to display a random hugging gif
embed = Embed(
title=f" | **{member.display_name}** hugged **{target.display_name}**",
colour=Colour(int(random.choice(colour_list))),
timestamp=time)
embed.set_image(url=random.choice(hugging_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
# Send the embedded message to the user
await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e:
print(e)
@command(name="marry", aliases=["Marry"])
@cooldown(1, 1, BucketType.user)
async def marry(self, ctx, member: Member):

Loading…
Cancel
Save