feat: Implement userService.getOrCreateUser and integrate it across commands, remove old utility scripts, and fix daily bonus calculation.

This commit is contained in:
syntaxbullet
2025-12-08 10:29:40 +01:00
parent 29c0a4752d
commit 866cfab03e
12 changed files with 42 additions and 94 deletions

View File

@@ -1,6 +1,7 @@
import { createCommand } from "@/lib/utils";
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
import { inventoryService } from "@/modules/inventory/inventory.service";
import { userService } from "@/modules/user/user.service";
export const inventory = createCommand({
data: new SlashCommandBuilder()
@@ -15,11 +16,12 @@ export const inventory = createCommand({
await interaction.deferReply();
const targetUser = interaction.options.getUser("user") || interaction.user;
const items = await inventoryService.getInventory(targetUser.id);
const user = await userService.getOrCreateUser(targetUser.id, targetUser.username);
const items = await inventoryService.getInventory(user.id);
if (!items || items.length === 0) {
const embed = new EmbedBuilder()
.setTitle(`${targetUser.username}'s Inventory`)
.setTitle(`${user.username}'s Inventory`)
.setDescription("Inventory is empty.")
.setColor("Blue");
@@ -32,7 +34,7 @@ export const inventory = createCommand({
}).join("\n");
const embed = new EmbedBuilder()
.setTitle(`${targetUser.username}'s Inventory`)
.setTitle(`${user.username}'s Inventory`)
.setDescription(description)
.setColor("Blue")
.setTimestamp();