From 2c91a6df2dfa1370a681551f07182258af688b37 Mon Sep 17 00:00:00 2001 From: AstreaTSS <25420078+AstreaTSS@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:29:49 -0500 Subject: [PATCH] fix: add check to make sure balances don't overflow --- exts/gacha/gacha_admin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exts/gacha/gacha_admin.py b/exts/gacha/gacha_admin.py index 045b0d3..e4203ac 100644 --- a/exts/gacha/gacha_admin.py +++ b/exts/gacha/gacha_admin.py @@ -488,7 +488,7 @@ async def gacha_give_all( if not ctx.guild.chunked: await ctx.guild.chunk() - await asyncio.sleep(1) # sometimes, it needs the wiggle room + await asyncio.sleep(1.5) # sometimes, it needs the wiggle room members = actual_role.members.copy() @@ -498,6 +498,12 @@ async def gacha_give_all( "user_id": {"in": [m.id for m in members]}, }, ) + if any(p.currency_amount + amount > 2147483647 for p in existing_players): + raise ipy.errors.BadArgument( + "One or more users would have more than the maximum amount of currency," + " 2,147,483,647, after this operation." + ) + existing_players_set = {p.user_id for p in existing_players} async with self.bot.db.batch_() as batch: