From 109f3114c96407725d50ce95f6a7300864510be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Sun, 6 Mar 2022 14:24:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20user=20has=20no=20credits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/credits/addons/gift.js | 10 ++++++++++ src/commands/credits/addons/give.js | 11 +++++++++++ src/commands/credits/addons/set.js | 11 +++++++++++ src/commands/credits/addons/take.js | 11 +++++++++++ 4 files changed, 43 insertions(+) diff --git a/src/commands/credits/addons/gift.js b/src/commands/credits/addons/gift.js index 589f5fc..52b5414 100644 --- a/src/commands/credits/addons/gift.js +++ b/src/commands/credits/addons/gift.js @@ -44,6 +44,16 @@ module.exports = async (interaction) => { const fromUser = await credits.findOne({ userId: interaction.user.id, guildId: interaction.member.guild.id }); const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id }); + if (!toUser) { + const embed = { + title: 'Set', + description: 'That user has no credits, I can not set credits to the user', + color: config.colors.error, + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + return interaction.editReply({ embeds: [embed], ephemeral: true }); + } fromUser.balance -= amount; toUser.balance += amount; diff --git a/src/commands/credits/addons/give.js b/src/commands/credits/addons/give.js index 9a3de69..a715f82 100644 --- a/src/commands/credits/addons/give.js +++ b/src/commands/credits/addons/give.js @@ -29,6 +29,17 @@ module.exports = async (interaction) => { return await interaction.editReply({ embeds: [embed], ephemeral: true }); } const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id }); + + if (!toUser) { + const embed = { + title: 'Set', + description: 'That user has no credits, I can not set credits to the user', + color: config.colors.error, + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + return interaction.editReply({ embeds: [embed], ephemeral: true }); + } toUser.balance += amount; await toUser.save(); const embed = { diff --git a/src/commands/credits/addons/set.js b/src/commands/credits/addons/set.js index 3344560..f4b6e28 100644 --- a/src/commands/credits/addons/set.js +++ b/src/commands/credits/addons/set.js @@ -21,6 +21,17 @@ module.exports = async (interaction) => { const amount = await interaction.options.getInteger('amount'); const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id }); + + if (!toUser) { + const embed = { + title: 'Set', + description: 'That user has no credits, I can not set credits to the user', + color: config.colors.error, + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + return interaction.editReply({ embeds: [embed], ephemeral: true }); + } toUser.balance = amount; await toUser.save(); diff --git a/src/commands/credits/addons/take.js b/src/commands/credits/addons/take.js index a3ac71c..4f4dae0 100644 --- a/src/commands/credits/addons/take.js +++ b/src/commands/credits/addons/take.js @@ -30,6 +30,17 @@ module.exports = async (interaction) => { return interaction.editReply({ embeds: [embed], ephemeral: true }); } const toUser = await credits.findOne({ userId: user.id, guildId: interaction.member.guild.id }); + + if (!toUser) { + const embed = { + title: 'Set', + description: 'That user has no credits, I can not set credits to the user', + color: config.colors.error, + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + return interaction.editReply({ embeds: [embed], ephemeral: true }); + } toUser.balance -= amount; await toUser.save();