Skip to content

Commit

Permalink
fix: negative deposit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2vw committed Mar 25, 2024
1 parent 565108a commit 2d0ba3f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ async def parse_amount(ctx, amount, bank=False):
)
return await ctx.reply(embed=embed)
return econ * (float(amount.replace("%", "")) / 100)
elif amount.lower() in ["a", "all", "everything", "max"]:
amount = user["economy"]["bank"]
return amount
elif "k" in amount.lower() or "thousand" in amount.lower():
return 1000 * int(amount.replace("k", "").replace("thousand", "").replace(" ", ""))
elif "m" in amount.lower() or "mil" in amount.lower() or "million" in amount.lower():
Expand Down Expand Up @@ -528,8 +531,10 @@ async def richest(ctx):
@limiter(10, on_ratelimited=lambda ctx, delay, *_1, **_2: ctx.send(f"You're on cooldown! Please wait `{round(delay, 2)}s`!"))
async def deposit(ctx, *, amount: str):
if (await userdb.find_one({"userid": ctx.author.id})):
amt = await parse_amount(ctx, amount, False)
amt = (await parse_amount(ctx, amount, False))
if amt is None:
print(amt)
print(amount)
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
Expand All @@ -538,6 +543,14 @@ async def deposit(ctx, *, amount: str):
)
await ctx.reply(embed=embed)
return
elif amt < 0:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description="Please enter a valid amount!",
color="#FF0000",
)
return await ctx.reply(embed=embed)
userdata = (await userdb.find_one({"userid": ctx.author.id}))["economy"]["wallet"]
if userdata > 0:
if amt > userdata:
Expand Down

0 comments on commit 2d0ba3f

Please sign in to comment.