2024-10-26 03:40:13 +01:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
|
|
|
const UserEconomy = require("../../models/UserEconomy");
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName("balance")
|
2024-10-26 19:33:45 +01:00
|
|
|
.setDescription("Check your balance and claim a bonus for checking daily!"),
|
2024-10-26 03:40:13 +01:00
|
|
|
|
|
|
|
async execute(interaction) {
|
|
|
|
const { user, guild } = interaction;
|
|
|
|
let userEconomy = await UserEconomy.findOne({
|
|
|
|
userId: user.id,
|
|
|
|
guildId: guild.id,
|
|
|
|
});
|
2024-10-26 19:33:45 +01:00
|
|
|
const checkInBonus = 10;
|
2024-10-26 03:40:13 +01:00
|
|
|
|
|
|
|
if (!userEconomy) {
|
|
|
|
userEconomy = await UserEconomy.create({
|
|
|
|
userId: user.id,
|
|
|
|
guildId: guild.id,
|
|
|
|
});
|
2024-10-26 19:33:45 +01:00
|
|
|
} else {
|
|
|
|
userEconomy.balance += checkInBonus;
|
|
|
|
await userEconomy.save();
|
2024-10-26 03:40:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor("#0099ff")
|
|
|
|
.setTitle(`${user.username}'s Balance`)
|
2024-10-26 19:33:45 +01:00
|
|
|
.setDescription(
|
|
|
|
`Your balance: **${userEconomy.balance}** coins. (Check-in Bonus: +${checkInBonus} coins)`
|
|
|
|
)
|
2024-10-26 03:40:13 +01:00
|
|
|
.setFooter({
|
|
|
|
text: `Requested by ${user.username}`,
|
|
|
|
iconURL: user.displayAvatarURL(),
|
2024-10-26 19:33:45 +01:00
|
|
|
})
|
|
|
|
.setTimestamp();
|
|
|
|
|
2024-10-26 03:40:13 +01:00
|
|
|
await interaction.reply({ embeds: [embed] });
|
|
|
|
},
|
|
|
|
};
|