From f0dccd2233e542b788cb2657c67d9b3a6d89ffde Mon Sep 17 00:00:00 2001 From: phixxy Date: Sat, 16 Mar 2024 00:38:47 -0700 Subject: [PATCH] try/except in budget and allow adding floats --- cogs/chatgpt.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/cogs/chatgpt.py b/cogs/chatgpt.py index a1b8da2..80de4a9 100644 --- a/cogs/chatgpt.py +++ b/cogs/chatgpt.py @@ -124,19 +124,25 @@ class ChatGPT(commands.Cog): return (flagged, categories, category_scores) @commands.command() - async def budget(self, ctx, command: str, budget: int): - if ctx.author.id == self.admin_id: - if command == "add": - self.dalle_budget += budget - await ctx.send(f"Budget increased by {budget}") - elif command == "remove": - self.dalle_budget -= budget - await ctx.send(f"Budget decreased by {budget}") - elif command == "set": - self.dalle_budget = budget - await ctx.send(f"Budget set to {budget}") - else: - await ctx.send(f"The current budget is {self.dalle_budget}") + async def budget(self, ctx, command: str, budget: float): + try: + if ctx.author.id == self.admin_id: + if command == "add": + self.dalle_budget += budget + await ctx.send(f"Budget increased by {budget}") + elif command == "remove": + self.dalle_budget -= budget + await ctx.send(f"Budget decreased by {budget}") + elif command == "set": + self.dalle_budget = budget + await ctx.send(f"Budget set to {budget}") + else: + await ctx.send(f"The current budget is {self.dalle_budget}") + else: + await ctx.send(f"The current budget is {self.dalle_budget}") + except Exception as e: + self.logger.exception(f"Budget command failed: {e}") + await ctx.send(f"Budget command failed") @commands.command(