From 1280a4f40c72a6fb5381136f14dad9747dbd472c Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sat, 11 Jul 2020 03:11:03 +0100 Subject: [PATCH] Adding Try/Except --- cogs/fun/homies.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cogs/fun/homies.py b/cogs/fun/homies.py index 10b9b1a3..e5163daa 100644 --- a/cogs/fun/homies.py +++ b/cogs/fun/homies.py @@ -54,17 +54,20 @@ class Fun(commands.Cog): async def homies(self, ctx, *, user_word): """Allows people to summon the homies""" - if len(user_word) >= 20: - await ctx.send("Please make sure the prompt is below **20** characters!") - return - else: + try: + if len(user_word) >= 20: + await ctx.send("Please make sure the prompt is below **20** characters!") + return + else: - top_text = f"Ayo fuck {user_word}" - bottom_text = f"All my homies hate {user_word}" + top_text = f"Ayo fuck {user_word}" + bottom_text = f"All my homies hate {user_word}" - generate_meme('homies/AllMyHomies.jpg', top_text=top_text, bottom_text=bottom_text) + generate_meme('homies/AllMyHomies.jpg', top_text=top_text, bottom_text=bottom_text) - await ctx.send(file=discord.File('meme-AllMyHomies.jpg')) + await ctx.send(file=discord.File('meme-AllMyHomies.jpg')) + except Exception as e: + print(e) def setup(bot):