forked from syntaxbullet/AuroraBot-discord
feat: Introduce new modules for class, inventory, leveling, and quests with expanded schema, refactor user service, and add verification scripts.
This commit is contained in:
@@ -1,29 +1,32 @@
|
||||
import { createCommand } from "@lib/utils";
|
||||
import { getUserBalance } from "@/modules/economy/economy.service";
|
||||
import { createUser, getUserById } from "@/modules/users/users.service";
|
||||
import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } from "discord.js";
|
||||
import { createCommand } from "@/lib/utils";
|
||||
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
|
||||
import { userService } from "@/modules/user/user.service";
|
||||
|
||||
export const balance = createCommand({
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("balance")
|
||||
.setDescription("Check your balance")
|
||||
.setDescription("Check your or another user's balance")
|
||||
.addUserOption(option =>
|
||||
option.setName("user")
|
||||
.setDescription("The user to check")
|
||||
.setRequired(false)
|
||||
),
|
||||
execute: async (interaction) => {
|
||||
await interaction.deferReply();
|
||||
|
||||
const targetUser = interaction.options.getUser("user") || interaction.user;
|
||||
const user = await userService.getUserById(targetUser.id);
|
||||
|
||||
, execute: async (interaction) => {
|
||||
const user = interaction.user;
|
||||
// Ensure user exists in DB
|
||||
let dbUser = await getUserById(user.id);
|
||||
if (!dbUser) {
|
||||
await createUser(user.id);
|
||||
if (!user) {
|
||||
await interaction.editReply({ content: "❌ User not found in database." });
|
||||
return;
|
||||
}
|
||||
|
||||
const balance = await getUserBalance(user.id);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${user.username}'s Balance`)
|
||||
.setDescription(`💰 **${balance} coins**`)
|
||||
.setColor("Green");
|
||||
.setAuthor({ name: targetUser.username, iconURL: targetUser.displayAvatarURL() })
|
||||
.setDescription(`**Balance**: ${user.balance || 0n} 🪙`)
|
||||
.setColor("Yellow");
|
||||
|
||||
await interaction.reply({ embeds: [embed] });
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user