🥅 user has no credits

This commit is contained in:
Axel Olausson Holtenäs 2022-03-06 14:24:33 +01:00
parent f47bdde051
commit 109f3114c9
No known key found for this signature in database
GPG key ID: E3AE7E194AE017ED
4 changed files with 43 additions and 0 deletions

View file

@ -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;

View file

@ -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 = {

View file

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

View file

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