From 129b23eb2bc7c1aee6d51f95646e442f1f4a08f9 Mon Sep 17 00:00:00 2001 From: Darien Rousseau <45698803+not-pyroman@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:31:50 -0600 Subject: [PATCH] Fix the balance checking of transferring + prevent sending to self Added the missing await operator and added a check to prevent players from trying to send themselves money --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e8b6170..446d1e0 100644 --- a/index.js +++ b/index.js @@ -290,16 +290,21 @@ client.on("interactionCreate", async interaction => { content: "You must specify an amount.", ephemeral: true }); - // Sanity check to make sure they arent trying to send negative coins and break the economy + // Sanity check to make sure they aren't trying to send negative coins and break the economy if (interaction.options.getNumber("amount") < 0) return interaction.reply({ content: "You cannot send negative coins you lil goober.", ephemeral: true }); + // Check if they're trying to be funny and send money to themselves. + if (interaction.user.id == interaction.options.getMember("user").user.id) return interaction.reply({ + content: "You can't send coins to yourself silly.", + ephemeral: true + }); // Round the input up (these fuckers found a dupe one fucking day into the bot, fuck you krill issue) let amount = interaction.options.getNumber("amount"); - balance = checkPoints(interaction.user); + balance = await checkPoints(interaction.user); if (balance < amount) return interaction.reply({ content: "You do not have enough coins.", ephemeral: true @@ -844,4 +849,4 @@ console.log(`${colors.cyan("[INFO]")} Starting...`) // Start timer to see how long startup takes const initTime = Date.now() // Login to Discord -client.login(config.discord.token); \ No newline at end of file +client.login(config.discord.token);