🚸 ✏️ 🚑 fix typo in take.js and added dm code
This commit is contained in:
parent
cd5bd79f69
commit
cf0073eced
2 changed files with 12 additions and 3 deletions
|
@ -20,6 +20,7 @@ module.exports = async (interaction) => {
|
||||||
const amount = await interaction.options.getInteger('amount');
|
const amount = await interaction.options.getInteger('amount');
|
||||||
|
|
||||||
const user = await credits.findOne({ userId: interaction.user.id });
|
const user = await credits.findOne({ userId: interaction.user.id });
|
||||||
|
const dmUser = interaction.client.users.cache.get(interaction.member.user.id);
|
||||||
|
|
||||||
if ((amount || user.balance) < 100) {
|
if ((amount || user.balance) < 100) {
|
||||||
const embed = {
|
const embed = {
|
||||||
|
@ -59,7 +60,7 @@ module.exports = async (interaction) => {
|
||||||
memo: `${interaction.createdTimestamp} - ${interaction.user.id}`,
|
memo: `${interaction.createdTimestamp} - ${interaction.user.id}`,
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const embed = {
|
const dmEmbed = {
|
||||||
title: 'Redeem',
|
title: 'Redeem',
|
||||||
description: `Your new balance is ${user.balance - (amount || user.balance)}.`,
|
description: `Your new balance is ${user.balance - (amount || user.balance)}.`,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -74,12 +75,20 @@ module.exports = async (interaction) => {
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
footer: { iconURL: __config.footer.icon, text: __config.footer.text },
|
footer: { iconURL: __config.footer.icon, text: __config.footer.text },
|
||||||
};
|
};
|
||||||
|
const interactionEmbed = {
|
||||||
|
title: 'Redeem',
|
||||||
|
description: `Code is sent in DM!`,
|
||||||
|
color: __config.colors.success,
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { iconURL: __config.footer.icon, text: __config.footer.text },
|
||||||
|
};
|
||||||
user.balance -= amount || user.balance;
|
user.balance -= amount || user.balance;
|
||||||
|
|
||||||
await user.save();
|
await user.save();
|
||||||
|
|
||||||
await logger.debug(`User: ${user.username} redeemed: ${creditNoun(amount)}`);
|
await logger.debug(`User: ${user.username} redeemed: ${creditNoun(amount)}`);
|
||||||
await interaction.editReply({ embeds: [embed], ephemeral: true });
|
await dmUser.send({ embeds: [dmEmbed] });
|
||||||
|
await interaction.editReply({ embeds: [interactionEmbed], ephemeral: true });
|
||||||
})
|
})
|
||||||
.catch(async (err) => {
|
.catch(async (err) => {
|
||||||
await logger.error(err);
|
await logger.error(err);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { Permissions } = require('discord.js');
|
const { Permissions } = require('discord.js');
|
||||||
|
|
||||||
const credits = require(`${__basedir}/helpers/database/models/creditScheme`);
|
const credits = require(`${__basedir}/helpers/database/models/creditSchema`);
|
||||||
const logger = require(`${__basedir}/handlers/logger`);
|
const logger = require(`${__basedir}/handlers/logger`);
|
||||||
const creditNoun = require(`${__basedir}/helpers/creditNoun`);
|
const creditNoun = require(`${__basedir}/helpers/creditNoun`);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue