forked from syntaxbullet/AuroraBot-discord
feat: Implement userService.getOrCreateUser and integrate it across commands, remove old utility scripts, and fix daily bonus calculation.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user