🚑 🎨 made creditNoun syncronous due /credits top
This commit is contained in:
parent
76fd813e98
commit
91b25452e8
8 changed files with 18 additions and 22 deletions
|
@ -24,7 +24,7 @@ module.exports = async (interaction) => {
|
|||
|
||||
const embed = {
|
||||
title: 'Balance',
|
||||
description: `${user ? `${user} has` : 'You have'} ${await creditNoun(balance)}.`,
|
||||
description: `${user ? `${user} has` : 'You have'} ${creditNoun(balance)}.`,
|
||||
color: process.env.SUCCESS_COLOR,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: process.env.FOOTER_ICON, text: process.env.FOOTER_TEXT },
|
||||
|
|
|
@ -48,9 +48,9 @@ module.exports = async (interaction) => {
|
|||
|
||||
const embed = {
|
||||
title: 'Gift',
|
||||
description: `You sent ${await creditNoun(
|
||||
description: `You sent ${creditNoun(
|
||||
amount
|
||||
)} to ${user}. Your new balance is ${await creditNoun(fromUser.balance)}.`,
|
||||
)} to ${user}. Your new balance is ${creditNoun(fromUser.balance)}.`,
|
||||
color: 0x22bb33,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: process.env.FOOTER_ICON, text: process.env.FOOTER_TEXT },
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = async (interaction) => {
|
|||
await toUser.save();
|
||||
const embed = {
|
||||
title: 'Give',
|
||||
description: `Gave ${await creditNoun(amount)} to ${user}.`,
|
||||
description: `Gave ${creditNoun(amount)} to ${user}.`,
|
||||
color: 0x22bb33,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: process.env.FOOTER_ICON, text: process.env.FOOTER_TEXT },
|
||||
|
|
|
@ -78,7 +78,7 @@ module.exports = async (interaction) => {
|
|||
|
||||
await user.save();
|
||||
|
||||
await logger.debug(`User: ${user.username} redeemed: ${await creditNoun(amount)}`);
|
||||
await logger.debug(`User: ${user.username} redeemed: ${creditNoun(amount)}`);
|
||||
await interaction.editReply({ embeds: [embed], ephemeral: true });
|
||||
})
|
||||
.catch(async (err) => {
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = async (interaction) => {
|
|||
|
||||
const embed = {
|
||||
title: 'Take',
|
||||
description: `You took ${await creditNoun(amount)} to ${user}.`,
|
||||
description: `You took ${creditNoun(amount)} to ${user}.`,
|
||||
color: 0x22bb33,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: process.env.FOOTER_ICON, text: process.env.FOOTER_TEXT },
|
||||
|
|
|
@ -4,14 +4,15 @@ const creditNoun = require('../../../helpers/creditNoun');
|
|||
|
||||
module.exports = async (interaction) => {
|
||||
await credits.find().then(async (data) => {
|
||||
const sorted = data.sort((a, b) => (a.balance > b.balance ? -1 : 1));
|
||||
const topTen = sorted.slice(0, 10);
|
||||
const topTen = data.sort((a, b) => (a.balance > b.balance ? -1 : 1)).slice(0, 10);
|
||||
|
||||
const item = (x, index) => {
|
||||
return `**Top ${index + 1}** - <@${x.userId}> ${creditNoun(x.balance)}`;
|
||||
};
|
||||
|
||||
const embed = {
|
||||
title: 'Balance Top',
|
||||
description: `Below are the top ten.\n${topTen
|
||||
.map((x, index) => `**Top ${index + 1}** - <@${x.userId}> ${await creditNoun(x.balance)}`)
|
||||
.join('\n')}`,
|
||||
description: `Below are the top ten.\n${topTen.map((x, index) => item(x, index)).join('\n')}`,
|
||||
color: 0x22bb33,
|
||||
timestamp: new Date(),
|
||||
footer: { iconURL: process.env.FOOTER_ICON, text: process.env.FOOTER_TEXT },
|
||||
|
|
|
@ -79,20 +79,15 @@ module.exports = {
|
|||
async execute(interaction) {
|
||||
if (interaction.options.getSubcommand() === 'balance') {
|
||||
await balance(interaction);
|
||||
}
|
||||
else if (interaction.options.getSubcommand() === 'gift') {
|
||||
} else if (interaction.options.getSubcommand() === 'gift') {
|
||||
await gift(interaction);
|
||||
}
|
||||
else if (interaction.options.getSubcommand() === 'give') {
|
||||
} else if (interaction.options.getSubcommand() === 'give') {
|
||||
await give(interaction);
|
||||
}
|
||||
else if (interaction.options.getSubcommand() === 'redeem') {
|
||||
} else if (interaction.options.getSubcommand() === 'redeem') {
|
||||
await redeem(interaction);
|
||||
}
|
||||
else if (interaction.options.getSubcommand() === 'take') {
|
||||
} else if (interaction.options.getSubcommand() === 'take') {
|
||||
await take(interaction);
|
||||
}
|
||||
else if (interaction.options.getSubcommand() === 'top') {
|
||||
} else if (interaction.options.getSubcommand() === 'top') {
|
||||
await top(interaction);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = async (amount) => {
|
||||
module.exports = (amount) => {
|
||||
return `${amount <= 1 ? `${amount} credit` : `${amount} credits`}`;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue