From 1be066ec59005b246f5290a114473d559c0643f1 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Thu, 18 Jun 2020 04:38:40 +0100 Subject: [PATCH] Trying to get errorFunction to work --- cogs/Embeds.py | 33 +++++++++++++++++++++++---------- cogs/FunCommands.py | 10 ++++++++-- cogs/WaifuImages.py | 24 ++++++++++++++++++++---- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/cogs/Embeds.py b/cogs/Embeds.py index 5b41ca78..51c8ea55 100644 --- a/cogs/Embeds.py +++ b/cogs/Embeds.py @@ -1,3 +1,4 @@ +import asyncio import datetime import random @@ -40,9 +41,13 @@ class Embeds(commands.Cog): await ctx.send(embed=embed) else: + message = error_function() + + # Let the user read the message for 2.5 seconds + await asyncio.sleep(2.5) + # Delete the message + await message.delete() - await errorFunction() - # except FileNotFoundError as e: print(e) @@ -70,8 +75,12 @@ class Embeds(commands.Cog): await ctx.send(embed=embed) else: + message = error_function() - await errorFunction() + # 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) @@ -100,8 +109,12 @@ class Embeds(commands.Cog): await ctx.send(embed=embed) else: + message = error_function() - await errorFunction() + # 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) @@ -130,15 +143,15 @@ class Embeds(commands.Cog): await ctx.send(embed=embed) else: - await errorFunction() + message = 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) - -def errorFunction(): - return error_function() - - def setup(bot): bot.add_cog(Embeds(bot)) diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index f29b4de0..e791bfb8 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -1,3 +1,4 @@ +import asyncio import random import discord @@ -5,7 +6,7 @@ from discord.ext import commands from discord.ext.commands import BucketType, cooldown import config -from cogs.Embeds import errorFunction +from EnsoBot import error_function colour_list = [c for c in config.colors.values()] @@ -117,7 +118,12 @@ class Fun(commands.Cog): else: - await errorFunction() + message = 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) diff --git a/cogs/WaifuImages.py b/cogs/WaifuImages.py index 7f9eda2e..9a68c9b0 100644 --- a/cogs/WaifuImages.py +++ b/cogs/WaifuImages.py @@ -1,3 +1,4 @@ +import asyncio import datetime import random import string @@ -7,7 +8,7 @@ from discord.ext import commands from discord.ext.commands import cooldown, BucketType import config -from cogs.Embeds import errorFunction +from EnsoBot import error_function channels = ["enso-chan-commands"] @@ -41,7 +42,12 @@ class Waifus(commands.Cog): else: - await errorFunction() + message = 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) @@ -69,7 +75,12 @@ class Waifus(commands.Cog): else: - await errorFunction() + message = 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) @@ -96,7 +107,12 @@ class Waifus(commands.Cog): else: - await errorFunction() + message = 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)