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();