Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.8 KiB
Python

import traceback
import sys
from discord.ext import commands
import discord
import configloader
class ErrorHandler(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
bot_app_info = await self.bot.application_info()
ignore_error = (commands.CommandNotFound, commands.UserInputError)
if isinstance(error, ignore_error):
return
elif isinstance(error, commands.CommandOnCooldown):
embed = configloader.embed.messageEmbed(f"This command is ratelimited, please try again in",
"{:.2f}s".format(error.retry_after),
f"{bot_app_info.owner}", f"{bot_app_info.icon_url}")
return await ctx.send(embed=embed)
elif isinstance(error, commands.NoPrivateMessage):
try:
embed = configloader.embed.messageEmbed(f"This Command can't be used in Private Messages.",
"{:.2f}s".format(ctx.command),
f"{bot_app_info.owner}", f"{bot_app_info.icon_url}")
return await ctx.author.send(embed=embed)
except:
pass
elif isinstance(error, commands.MissingPermissions):
embed = configloader.embed.messageEmbed(f"You don't have Permissions to use this command",
"{:.2f}s".format(ctx.command),
f"{bot_app_info.owner}", f"{bot_app_info.icon_url}")
return await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(ErrorHandler(bot))