🚑 forgot to save users and do it in a try catch

This commit is contained in:
Axel Olausson Holtenäs 2022-02-27 22:32:12 +01:00
parent 73f9f91a8b
commit 8b8343a26f
No known key found for this signature in database
GPG key ID: E3AE7E194AE017ED

View file

@ -3,6 +3,7 @@ const debug = require('../../../handlers/debug');
const saveUser = require('../../../helpers/saveUser'); const saveUser = require('../../../helpers/saveUser');
module.exports = async (interaction) => { module.exports = async (interaction) => {
try {
const user = await interaction.options.getUser('user'); const user = await interaction.options.getUser('user');
const amount = await interaction.options.getInteger('amount'); const amount = await interaction.options.getInteger('amount');
const data = await credits.findOne({ userId: interaction.user.id }); const data = await credits.findOne({ userId: interaction.user.id });
@ -42,6 +43,8 @@ module.exports = async (interaction) => {
fromUser.balance -= amount; fromUser.balance -= amount;
toUser.balance += amount; toUser.balance += amount;
saveUser(fromUser, toUser);
const embed = { const embed = {
title: 'Gift', title: 'Gift',
description: `You sent ${ description: `You sent ${
@ -55,4 +58,7 @@ module.exports = async (interaction) => {
return await interaction.editReply({ embeds: [embed], ephemeral: true }); return await interaction.editReply({ embeds: [embed], ephemeral: true });
} }
} }
} catch {
async (err) => debug(err);
}
}; };