From 03e7111604a786e212e7b55f6d9ca9f84be9b432 Mon Sep 17 00:00:00 2001 From: Parker Date: Tue, 25 Mar 2025 23:17:22 -0500 Subject: [PATCH] Protect against errors --- code/cogs/owner/toggle.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/cogs/owner/toggle.py b/code/cogs/owner/toggle.py index a276b01..bdb4b4a 100644 --- a/code/cogs/owner/toggle.py +++ b/code/cogs/owner/toggle.py @@ -19,7 +19,12 @@ class Toggle(commands.Cog): self.bot.youtube_broken = True return await ctx.send("YouTube has been marked as broken.") - await ctx.send("Invalid action. Please use 'on' or 'off'.") + @toggle.error + async def toggle_error(self, ctx, error): + if isinstance(error, commands.BadLiteralArgument): + return await ctx.send("Invalid action. Use either 'on' or 'off'.") + else: + return await ctx.send("An unknown error occurred.") async def setup(bot):