From ba0d3d7679ecc8ab72c50497007fcefbd88bf933 Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Fri, 3 Oct 2025 00:27:46 +0200 Subject: [PATCH] bump v2 --- plugins/Commands/src/commands/nekoslife.ts | 85 ++++++++++++---------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/plugins/Commands/src/commands/nekoslife.ts b/plugins/Commands/src/commands/nekoslife.ts index b54cb43..37e2c12 100644 --- a/plugins/Commands/src/commands/nekoslife.ts +++ b/plugins/Commands/src/commands/nekoslife.ts @@ -9,31 +9,11 @@ interface NekosLifeResult { url: string; } -// Only SFW categories (exactly 16 - within Discord's 25 choice limit) -const categoryChoices = [ - { name: "Avatar", value: "avatar" }, - { name: "Classic", value: "classic" }, - { name: "Cuddle", value: "cuddle" }, - { name: "Fox Girl", value: "fox_girl" }, - { name: "Gecg", value: "gecg" }, - { name: "Holo", value: "holo" }, - { name: "Kemonomimi", value: "kemonomimi" }, - { name: "Kiss", value: "kiss" }, - { name: "Neko", value: "neko" }, - { name: "Neko GIF", value: "ngif" }, - { name: "Smug", value: "smug" }, - { name: "Spank", value: "spank" }, - { name: "Tickle", value: "tickle" }, - { name: "Waifu", value: "waifu" }, - { name: "Wallpaper", value: "wallpaper" }, - { name: "Woof", value: "woof" } -]; - -const limitChoices = [ - { name: "1", value: 1 }, - { name: "2", value: 2 }, - { name: "3", value: 3 }, - { name: "5", value: 5 } +// Valid SFW categories for validation +const validSfwCategories = [ + "avatar", "classic", "cuddle", "fox_girl", "gecg", "holo", + "kemonomimi", "kiss", "neko", "ngif", "smug", "spank", + "tickle", "waifu", "wallpaper", "woof" ]; async function fetchNekosLifeImages(category: string, count: number): Promise { @@ -64,6 +44,11 @@ async function fetchNekosLifeImages(category: string, count: number): Promise arg.name === "category")?.value; - const limit = args.find((arg: any) => arg.name === "limit")?.value || 1; + const categoryInput = args.find((arg: any) => arg.name === "category")?.value; + const limitInput = args.find((arg: any) => arg.name === "limit")?.value; 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] Parsed values:', { category, limit, shouldSend, isEphemeral }); + console.log('[NekosLife] Parsed values:', { categoryInput, limitInput, shouldSend, isEphemeral }); - if (!category) { - const errorMsg = "❌ Category is required!"; + if (!categoryInput || typeof categoryInput !== 'string') { + const errorMsg = "❌ Category is required! Examples: neko, waifu, cuddle, kiss"; console.error('[NekosLife] No category provided'); if (isEphemeral) { @@ -134,6 +117,32 @@ export const nekoslifeCommand = { return { type: 4 }; } + // Clean and validate category + const category = categoryInput.toLowerCase().trim(); + + if (!isValidSfwCategory(category)) { + const errorMsg = `❌ Invalid SFW category "${categoryInput}". Valid: neko, waifu, cuddle, kiss, holo, etc.`; + + if (isEphemeral) { + return { + type: 4, + data: { + content: errorMsg, + flags: 64, + }, + }; + } + showToast(errorMsg, getAssetIDByName("CircleXIcon")); + return { type: 4 }; + } + + // Parse and validate limit + let limit = 1; + if (limitInput !== undefined && limitInput !== null) { + limit = parseInt(String(limitInput)) || 1; + limit = Math.max(1, Math.min(5, limit)); // Clamp between 1-5 + } + console.log('[NekosLife] Processing SFW request:', { category, limit, shouldSend, isEphemeral }); // Show loading toast