This commit is contained in:
2025-11-26 19:34:08 +05:00
commit 1dd4394e4b
11 changed files with 926 additions and 0 deletions

63
c/error.py Normal file
View File

@@ -0,0 +1,63 @@
import discord
import traceback
import sys
from discord.ext import commands
class Error(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if hasattr(ctx.command, "on_error"):
return
cog = ctx.cog
if cog:
if cog._get_overridden_method(cog.cog_command_error) is not None:
return
ignored = (commands.CommandNotFound,)
error = getattr(error, "original", error)
if isinstance(error, ignored):
return
if isinstance(error, commands.DisabledCommand):
await ctx.send(f"{ctx.command} has been disabled.")
elif isinstance(error, commands.NoPrivateMessage):
try:
await ctx.author.send(
f"{ctx.command} can not be used in Private Messages."
)
except discord.HTTPException:
pass
elif isinstance(error, commands.BadArgument):
if ctx.command.qualified_name == "tag list":
await ctx.send("I could not find that member. Please try again.")
elif isinstance(error, commands.MissingPermissions):
await ctx.reply("Ээм друк у тебя нет прав на использование этой команды!!")
elif isinstance(error, commands.NotOwner):
await ctx.reply("Эта команда доступна только владельцу бота!!!")
else:
print(
"Ignoring exception in command {}:".format(ctx.command), file=sys.stderr
)
# traceback.print_exception(
# type(error), error, error.__traceback__, file=sys.stderr
# )
print(error)
@commands.Cog.listener()
async def on_ready(self):
print('Error cog has been loaded')
async def setup(bot):
await bot.add_cog(Error(bot))