From c87a9422e3af7805d38f4cd78271f7ceb131ef28 Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Thu, 2 Oct 2025 23:35:22 +0200 Subject: [PATCH] explode --- plugins/Commands/src/commands/nekoslife.ts | 49 +++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/plugins/Commands/src/commands/nekoslife.ts b/plugins/Commands/src/commands/nekoslife.ts index ec287b2..fa4f4fb 100644 --- a/plugins/Commands/src/commands/nekoslife.ts +++ b/plugins/Commands/src/commands/nekoslife.ts @@ -103,6 +103,8 @@ async function fetchNekosLifeImages(category: string, count: number): Promise { try { - const category = args.find((arg: any) => arg.name === "category")?.value; - const limitStr = args.find((arg: any) => arg.name === "limit")?.value || "1"; - const shouldSend = args.find((arg: any) => arg.name === "send")?.value || false; - const isEphemeral = args.find((arg: any) => arg.name === "ephemeral")?.value || false; + console.log('[NekosLife] Command executed with args:', args); - if (!category) { - const errorMsg = "❌ Category is required!"; + // Better argument parsing with fallbacks + let category: string | undefined; + let limitStr: string = "1"; + let shouldSend: boolean = false; + let isEphemeral: boolean = false; + + // Handle different argument formats + if (Array.isArray(args)) { + category = args.find((arg: any) => arg?.name === "category")?.value; + limitStr = args.find((arg: any) => arg?.name === "limit")?.value || "1"; + shouldSend = args.find((arg: any) => arg?.name === "send")?.value || false; + isEphemeral = args.find((arg: any) => arg?.name === "ephemeral")?.value || false; + } else if (args && typeof args === 'object') { + category = args.category?.value || args.category; + limitStr = args.limit?.value || args.limit || "1"; + shouldSend = args.send?.value || args.send || false; + isEphemeral = args.ephemeral?.value || args.ephemeral || false; + } + + console.log('[NekosLife] Parsed values:', { category, limitStr, shouldSend, isEphemeral }); + + if (!category || typeof category !== 'string') { + const errorMsg = "❌ Category is required and must be a valid string!"; + console.error('[NekosLife] Invalid category:', category); + if (isEphemeral) { return { type: 4, @@ -183,11 +205,13 @@ export const nekoslifeCommand = { return { type: 4 }; } - const limit = parseInt(limitStr); + const limit = parseInt(limitStr) || 1; const isNsfw = isNsfwCategory(category); + console.log('[NekosLife] Processing request:', { category, limit, isNsfw, shouldSend, isEphemeral }); + // Check if trying to send NSFW content in non-NSFW channel - if (shouldSend && !isEphemeral && isNsfw && !ctx.channel.nsfw) { + if (shouldSend && !isEphemeral && isNsfw && !ctx.channel?.nsfw) { alerts.showConfirmationAlert({ title: "⚠️ NSFW Content Warning", content: "This category contains NSFW content and can only be sent in NSFW channels!", @@ -222,6 +246,7 @@ export const nekoslifeCommand = { const content = urls.join("\n"); if (isEphemeral) { + console.log('[NekosLife] Sending ephemeral response'); return { type: 4, data: { @@ -230,10 +255,12 @@ export const nekoslifeCommand = { }, }; } else if (shouldSend) { + console.log('[NekosLife] Sending to chat'); const fixNonce = Date.now().toString(); MessageActions.sendMessage(ctx.channel.id, { content }, void 0, { nonce: fixNonce }); return { type: 4 }; } else { + console.log('[NekosLife] Sending as bot message'); // Send as bot message (ephemeral-like) messageUtil.sendBotMessage(ctx.channel.id, content); return { type: 4 }; @@ -242,7 +269,9 @@ export const nekoslifeCommand = { console.error('[NekosLife] Command error:', error); const errorMessage = "❌ An error occurred while fetching images."; - const isEphemeral = args?.find?.((arg: any) => arg.name === "ephemeral")?.value ?? false; + const isEphemeral = Array.isArray(args) + ? args?.find?.((arg: any) => arg?.name === "ephemeral")?.value ?? false + : args?.ephemeral?.value || args?.ephemeral || false; if (isEphemeral) { return {