Initial commit

This commit is contained in:
Nemika
2021-03-07 20:55:27 +02:00
commit 2ccb1e6bbc
13 changed files with 355 additions and 0 deletions

26
cogs/handler.py Normal file
View File

@@ -0,0 +1,26 @@
import discord
from core import embeds
commands = discord.ext.commands
class ErrorHandler(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
return await ctx.send(embed=embeds.Embeds(f"Missing `{error.param}` as a required argument.").error())
elif isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, commands.CheckAnyFailure):
return await ctx.send(embed=embeds.Embeds("You are not allowed to do this.").error())
elif isinstance(error, commands.CommandOnCooldown):
seconds = error.retry_after
return await ctx.send(embed=embeds.Embeds(f"**You are on cooldown!** You can use this command again in **{seconds} seconds**.").error())
else:
await ctx.send(embed=embeds.Embeds("There was an error executing this command.").error(Error=error))
raise error
def setup(bot):
bot.add_cog(ErrorHandler(bot))