From 0534451d64c84039b4d61a90bbfe1f15e33adfdb Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 22 Oct 2022 16:38:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20verify=20amount=20<=20100.000.00?= =?UTF-8?q?0=20else=20throw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/transferCredits/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/helpers/transferCredits/index.ts b/src/helpers/transferCredits/index.ts index 46dcf8e..51f4eee 100644 --- a/src/helpers/transferCredits/index.ts +++ b/src/helpers/transferCredits/index.ts @@ -57,13 +57,18 @@ export default async (guild: Guild, from: User, to: User, amount: number) => { throw new Error("You can't transfer below one credit."); } - // 6. Verify that recipient are not an bot. + // 6. Verify that the sender is not trying to send more than 100.000.000 credits. + if (amount > 100000000) { + throw new Error("You can't transfer more than 100.000.000 credits."); + } + + // 7. Verify that recipient are not an bot. if (to.bot) throw new Error("You can't transfer to an bot."); - // 7. Verify that sender and recipient are not the same user. + // 8. Verify that sender and recipient are not the same user. if (from.id === to.id) throw new Error("You can't transfer to yourself."); - // 8. Increment the recipient's balance by amount. + // 9. Increment the recipient's balance by amount. const recipient = await tx.guildMember.upsert({ update: { creditsEarned: {