try/except in budget and allow adding floats

This commit is contained in:
phixxy 2024-03-16 00:38:47 -07:00
parent 3786a1434a
commit f0dccd2233

View file

@ -124,19 +124,25 @@ class ChatGPT(commands.Cog):
return (flagged, categories, category_scores) return (flagged, categories, category_scores)
@commands.command() @commands.command()
async def budget(self, ctx, command: str, budget: int): async def budget(self, ctx, command: str, budget: float):
if ctx.author.id == self.admin_id: try:
if command == "add": if ctx.author.id == self.admin_id:
self.dalle_budget += budget if command == "add":
await ctx.send(f"Budget increased by {budget}") self.dalle_budget += budget
elif command == "remove": await ctx.send(f"Budget increased by {budget}")
self.dalle_budget -= budget elif command == "remove":
await ctx.send(f"Budget decreased by {budget}") self.dalle_budget -= budget
elif command == "set": await ctx.send(f"Budget decreased by {budget}")
self.dalle_budget = budget elif command == "set":
await ctx.send(f"Budget set to {budget}") self.dalle_budget = budget
else: await ctx.send(f"Budget set to {budget}")
await ctx.send(f"The current budget is {self.dalle_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( @commands.command(