🥅 user has no credits
This commit is contained in:
parent
f47bdde051
commit
109f3114c9
4 changed files with 43 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue