mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 16:55:55 +00:00
36 lines
979 B
JavaScript
36 lines
979 B
JavaScript
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||
|
const UserEconomy = require("../../models/UserEconomy");
|
||
|
|
||
|
module.exports = {
|
||
|
data: new SlashCommandBuilder()
|
||
|
.setName("balance")
|
||
|
.setDescription("Check your balance"),
|
||
|
|
||
|
async execute(interaction) {
|
||
|
const { user, guild } = interaction;
|
||
|
|
||
|
let userEconomy = await UserEconomy.findOne({
|
||
|
userId: user.id,
|
||
|
guildId: guild.id,
|
||
|
});
|
||
|
|
||
|
if (!userEconomy) {
|
||
|
userEconomy = await UserEconomy.create({
|
||
|
userId: user.id,
|
||
|
guildId: guild.id,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
const embed = new EmbedBuilder()
|
||
|
.setColor("#0099ff")
|
||
|
.setTitle(`${user.username}'s Balance`)
|
||
|
.setDescription(`You have **${userEconomy.balance}** coins.`)
|
||
|
.setTimestamp()
|
||
|
.setFooter({
|
||
|
text: `Requested by ${user.username}`,
|
||
|
iconURL: user.displayAvatarURL(),
|
||
|
});
|
||
|
await interaction.reply({ embeds: [embed] });
|
||
|
},
|
||
|
};
|