diff --git a/cogs/welcome_cog.py b/cogs/welcome_cog.py index cdd57cc..2b218aa 100644 --- a/cogs/welcome_cog.py +++ b/cogs/welcome_cog.py @@ -435,29 +435,28 @@ class WelcomeCog(commands.Cog): await ctx.send("An unexpected error occurred.", ephemeral=True) # Error Handling for this Cog - @set_welcome.error - @disable_welcome.error - @set_goodbye.error - @disable_goodbye.error - @testmessage.error - async def on_command_error(self, ctx: commands.Context, error): + async def cog_command_error(self, ctx: commands.Context, error: commands.CommandError): + """Handles errors for all commands in this cog.""" if isinstance(error, commands.MissingPermissions): - await ctx.send("You need Administrator permissions to use this command.") + await ctx.send("You need Administrator permissions to use this command.", ephemeral=True) elif isinstance(error, commands.BadArgument): await ctx.send( - f"Invalid argument provided. Check the command help: `{ctx.prefix}help {ctx.command.name}`" + f"Invalid argument provided. Check the command help: `{ctx.prefix}help {ctx.command.name}`", + ephemeral=True ) elif isinstance(error, commands.MissingRequiredArgument): await ctx.send( - f"Missing required argument. Check the command help: `{ctx.prefix}help {ctx.command.name}`" + f"Missing required argument. Check the command help: `{ctx.prefix}help {ctx.command.name}`", + ephemeral=True ) elif isinstance(error, commands.NoPrivateMessage): - await ctx.send("This command cannot be used in private messages.") + await ctx.send("This command cannot be used in private messages.", ephemeral=True) else: + original_error = getattr(error, 'original', error) log.error( - f"Unhandled error in WelcomeCog command '{ctx.command.name}': {error}" + f"Unhandled error in WelcomeCog command '{ctx.command.name}': {original_error}" ) - await ctx.send("An unexpected error occurred. Please check the logs.") + await ctx.send("An unexpected error occurred. Please check the logs.", ephemeral=True) async def setup(bot: commands.Bot):