From 1039d8feb8d4f5ebd8e8b6100ddd5de24287aeb3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:58:35 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Deny=20to=20bot=20and=20from=20a?= =?UTF-8?q?nd=20to=20same=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/transferCredits.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/helpers/transferCredits.ts b/src/helpers/transferCredits.ts index 4d648ba..58d96b0 100644 --- a/src/helpers/transferCredits.ts +++ b/src/helpers/transferCredits.ts @@ -54,10 +54,16 @@ export default async (guild: Guild, from: User, to: User, amount: number) => { // 5. Verify that the sender is not trying to send less that one credits. if (amount <= 0) { - throw new Error("You can't give negative amounts."); + throw new Error("You can't transfer below one credit."); } - // 6. Increment the recipient's balance by amount + // 6. 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. + if (from.id === to.id) throw new Error("You can't transfer to yourself."); + + // 8. Increment the recipient's balance by amount. const recipient = await tx.guildMember.upsert({ update: { creditsEarned: {