From a2315ba0e284289b7c299266b7273c4e28856879 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sat, 27 Jun 2020 00:10:02 +0100 Subject: [PATCH] Adding Digby command --- cogs/FunCommands.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index eb42d02c..fcfb2e02 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -206,6 +206,38 @@ class Fun(commands.Cog): # Instantly Send message to user's dms await author.send(text) + # ~digby command that allows users to see a picture of digby + @commands.command(aliases=["Digby"]) + async def digby(self, ctx): + + # Surround with try/except to catch any exceptions that may occur + try: + + # Open the file containing the digby images + with open('images/digby.txt') as file: + # Store content of the file in digby_array + digby_array = file.readlines() + + # Set member as the author + member = ctx.message.author + # Get the member avatar + userAvatar = member.avatar_url + + # Set up the embed to display a random image of digby + embed = discord.Embed( + title=f"**A cute picture of Digby!**", + colour=discord.Colour(int(random.choice(settings.colour_list)))) + embed.set_image(url=random.choice(digby_array)) + embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) + embed.timestamp = datetime.datetime.utcnow() + + # Send the embedded message to the user + await ctx.send(embed=embed) + + except FileNotFoundError as e: + print(e) + + # ~Doggo command @commands.command(aliases=["Doggo"]) @cooldown(1, 1, BucketType.user) async def doggo(self, ctx, breed=None):