refactor(economy): enhance type definitions and improve channel message handling

This commit is contained in:
2025-10-05 05:19:16 -05:00
parent 68f629d637
commit c868e3bf80
10 changed files with 32 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
import { prisma } from '../../core/database/prisma';
import { Prisma } from '@prisma/client';
async function upsertEconomyItem(guildId: string | null, key: string, data: Omit<Parameters<typeof prisma.economyItem.create>[0]['data'], 'key' | 'guildId'>) {
async function upsertEconomyItem(guildId: string | null, key: string, data: Omit<Prisma.EconomyItemUncheckedCreateInput, 'key' | 'guildId'>) {
if (guildId) {
return prisma.economyItem.upsert({ where: { guildId_key: { guildId, key } }, update: {}, create: { ...data, key, guildId } });
}
@@ -10,7 +10,7 @@ async function upsertEconomyItem(guildId: string | null, key: string, data: Omit
return prisma.economyItem.create({ data: { ...data, key, guildId: null } });
}
async function upsertGameArea(guildId: string | null, key: string, data: Omit<Parameters<typeof prisma.gameArea.create>[0]['data'], 'key' | 'guildId'>) {
async function upsertGameArea(guildId: string | null, key: string, data: Omit<Prisma.GameAreaUncheckedCreateInput, 'key' | 'guildId'>) {
if (guildId) {
return prisma.gameArea.upsert({ where: { guildId_key: { guildId, key } }, update: {}, create: { ...data, key, guildId } });
}
@@ -19,7 +19,7 @@ async function upsertGameArea(guildId: string | null, key: string, data: Omit<Pa
return prisma.gameArea.create({ data: { ...data, key, guildId: null } });
}
async function upsertMob(guildId: string | null, key: string, data: Omit<Parameters<typeof prisma.mob.create>[0]['data'], 'key' | 'guildId'>) {
async function upsertMob(guildId: string | null, key: string, data: Omit<Prisma.MobUncheckedCreateInput, 'key' | 'guildId'>) {
if (guildId) {
return prisma.mob.upsert({ where: { guildId_key: { guildId, key } }, update: { stats: (data as any).stats, drops: (data as any).drops, name: (data as any).name }, create: { ...data, key, guildId } });
}

View File

@@ -64,7 +64,7 @@ async function validateRequirements(userId: string, guildId: string, req?: Level
// Auto-select tool when required and not provided
if (!toolKeyUsed && toolReq.required && toolReq.toolType) {
toolKeyUsed = await findBestToolKey(userId, guildId, toolReq.toolType, { minTier: toolReq.minTier, allowedKeys: toolReq.allowedKeys });
toolKeyUsed = await findBestToolKey(userId, guildId, toolReq.toolType, { minTier: toolReq.minTier, allowedKeys: toolReq.allowedKeys }) ?? undefined;
}
// herramienta requerida