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:
syntaxbullet
2025-12-07 23:03:33 +01:00
parent be471f348d
commit 29c0a4752d
21 changed files with 1228 additions and 163 deletions

View File

@@ -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] });
}
});
});