diff --git a/unbelievaboat/business.py b/unbelievaboat/business.py index b8045be..92e35c3 100644 --- a/unbelievaboat/business.py +++ b/unbelievaboat/business.py @@ -171,19 +171,39 @@ class Business(commands.Cog): if len(businesses) >= 3: return await ctx.send("You can only own up to 3 businesses!") - cost = business_types[business_type]["cost"] - if not await bank.can_spend(ctx.author, cost): - return await ctx.send(f"You need ${cost:,} to start this business!") + cost = int(business_types[business_type]["cost"]) # Ensure cost is an integer + current_balance = await bank.get_balance(ctx.author) + max_balance = await bank.get_max_balance(ctx.guild) - await bank.withdraw_credits(ctx.author, cost) - businesses[business_name] = { - "type": business_type, - "employees": business_types[business_type]["employees"]["min"], - "upgrades": [], - "last_collection": None - } - - await ctx.send(f"Congratulations! You are now the proud owner of {business_name}!") + # Debug information + debug_msg = ( + f"Debug Info:\n" + f"- Your current balance: ${current_balance:,}\n" + f"- Business cost: ${cost:,}\n" + f"- Max possible balance: ${max_balance:,}\n" + f"- Can spend: {await bank.can_spend(ctx.author, cost)}" + ) + await ctx.send(debug_msg) + + if not await bank.can_spend(ctx.author, cost): + return await ctx.send( + f"You need ${cost:,} to start this business! " + f"(You have ${current_balance:,})" + ) + + try: + await bank.withdraw_credits(ctx.author, cost) + businesses[business_name] = { + "type": business_type, + "employees": business_types[business_type]["employees"]["min"], + "upgrades": [], + "last_collection": None + } + await ctx.send(f"Congratulations! You are now the proud owner of {business_name}!") + except ValueError as e: + await ctx.send(f"Error occurred while trying to withdraw credits: {str(e)}") + except Exception as e: + await ctx.send(f"An unexpected error occurred: {str(e)}") @business.command(name="view") async def view_business(self, ctx, *, business_name: str = None):