bump v2
This commit is contained in:
parent
ddc0390b6b
commit
ba0d3d7679
1 changed files with 47 additions and 38 deletions
|
|
@ -9,31 +9,11 @@ interface NekosLifeResult {
|
||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only SFW categories (exactly 16 - within Discord's 25 choice limit)
|
// Valid SFW categories for validation
|
||||||
const categoryChoices = [
|
const validSfwCategories = [
|
||||||
{ name: "Avatar", value: "avatar" },
|
"avatar", "classic", "cuddle", "fox_girl", "gecg", "holo",
|
||||||
{ name: "Classic", value: "classic" },
|
"kemonomimi", "kiss", "neko", "ngif", "smug", "spank",
|
||||||
{ name: "Cuddle", value: "cuddle" },
|
"tickle", "waifu", "wallpaper", "woof"
|
||||||
{ 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 }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
async function fetchNekosLifeImages(category: string, count: number): Promise<string[]> {
|
async function fetchNekosLifeImages(category: string, count: number): Promise<string[]> {
|
||||||
|
|
@ -64,6 +44,11 @@ async function fetchNekosLifeImages(category: string, count: number): Promise<st
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidSfwCategory(category: string): boolean {
|
||||||
|
if (!category || typeof category !== 'string') return false;
|
||||||
|
return validSfwCategories.includes(category.toLowerCase().trim());
|
||||||
|
}
|
||||||
|
|
||||||
export const nekoslifeCommand = {
|
export const nekoslifeCommand = {
|
||||||
name: "nekoslife",
|
name: "nekoslife",
|
||||||
displayName: "nekoslife",
|
displayName: "nekoslife",
|
||||||
|
|
@ -73,20 +58,18 @@ export const nekoslifeCommand = {
|
||||||
{
|
{
|
||||||
name: "category",
|
name: "category",
|
||||||
displayName: "category",
|
displayName: "category",
|
||||||
description: "Category of SFW image/gif to get",
|
description: "Category name (e.g. neko, waifu, cuddle, etc.)",
|
||||||
displayDescription: "Category of SFW image/gif to get",
|
displayDescription: "Category name (e.g. neko, waifu, cuddle, etc.)",
|
||||||
type: 3, // String
|
type: 3, // String - free text input
|
||||||
required: true,
|
required: true,
|
||||||
choices: categoryChoices
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "limit",
|
name: "limit",
|
||||||
displayName: "limit",
|
displayName: "limit",
|
||||||
description: "Number of images to get (default: 1)",
|
description: "Number of images (1-5, default: 1)",
|
||||||
displayDescription: "Number of images to get (default: 1)",
|
displayDescription: "Number of images (1-5, default: 1)",
|
||||||
type: 4, // Integer
|
type: 4, // Integer
|
||||||
required: false,
|
required: false,
|
||||||
choices: limitChoices
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "send",
|
name: "send",
|
||||||
|
|
@ -110,15 +93,15 @@ export const nekoslifeCommand = {
|
||||||
console.log('[NekosLife] Command executed with args:', args);
|
console.log('[NekosLife] Command executed with args:', args);
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
const category = args.find((arg: any) => arg.name === "category")?.value;
|
const categoryInput = args.find((arg: any) => arg.name === "category")?.value;
|
||||||
const limit = args.find((arg: any) => arg.name === "limit")?.value || 1;
|
const limitInput = args.find((arg: any) => arg.name === "limit")?.value;
|
||||||
const shouldSend = args.find((arg: any) => arg.name === "send")?.value || false;
|
const shouldSend = args.find((arg: any) => arg.name === "send")?.value || false;
|
||||||
const isEphemeral = args.find((arg: any) => arg.name === "ephemeral")?.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) {
|
if (!categoryInput || typeof categoryInput !== 'string') {
|
||||||
const errorMsg = "❌ Category is required!";
|
const errorMsg = "❌ Category is required! Examples: neko, waifu, cuddle, kiss";
|
||||||
console.error('[NekosLife] No category provided');
|
console.error('[NekosLife] No category provided');
|
||||||
|
|
||||||
if (isEphemeral) {
|
if (isEphemeral) {
|
||||||
|
|
@ -134,6 +117,32 @@ export const nekoslifeCommand = {
|
||||||
return { type: 4 };
|
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 });
|
console.log('[NekosLife] Processing SFW request:', { category, limit, shouldSend, isEphemeral });
|
||||||
|
|
||||||
// Show loading toast
|
// Show loading toast
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue