@zerospacegg/vynthra
Version:
Discord bot for ZeroSpace.gg data
87 lines • 3.24 kB
TypeScript
import type { BotSubcommand } from "./types.js";
import type { SlashCommandSubcommandBuilder, ChatInputCommandInteraction } from "discord.js";
/**
* Helper function to create a custom subcommand for the bot
*
* @param name - The name of the subcommand
* @param description - The description of the subcommand
* @param builder - Function to configure the subcommand options
* @param execute - Function to handle the subcommand execution
* @returns A BotSubcommand object ready to be registered
*
* @example
* ```typescript
* const mySubcommand = createSubcommand(
* "mycommand",
* "My custom command description",
* (subcommand) => subcommand
* .addStringOption(option =>
* option
* .setName("input")
* .setDescription("Some input")
* .setRequired(true)
* ),
* async (interaction) => {
* const input = interaction.options.getString("input", true);
* await interaction.reply(`You said: ${input}`);
* }
* );
* ```
*/
export declare function createSubcommand(name: string, description: string, builder: (subcommand: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder, execute: (interaction: ChatInputCommandInteraction) => Promise<void>): BotSubcommand;
/**
* Helper function to create a simple subcommand with just a query parameter
* This is useful for commands that follow the same pattern as the stats command
*
* @param name - The name of the subcommand
* @param description - The description of the subcommand
* @param queryDescription - Description for the query parameter
* @param execute - Function to handle the subcommand execution
* @returns A BotSubcommand object ready to be registered
*
* @example
* ```typescript
* const searchSubcommand = createQuerySubcommand(
* "search",
* "Search for something",
* "What to search for",
* async (interaction) => {
* const query = interaction.options.getString("query", true);
* // Handle search logic here
* await interaction.reply(`Searching for: ${query}`);
* }
* );
* ```
*/
export declare function createQuerySubcommand(name: string, description: string, queryDescription: string, execute: (interaction: ChatInputCommandInteraction) => Promise<void>): BotSubcommand;
/**
* Validates that a subcommand has all required properties
*
* @param subcommand - The subcommand to validate
* @throws Error if the subcommand is invalid
*/
export declare function validateSubcommand(subcommand: BotSubcommand): void;
/**
* Validates an array of subcommands
*
* @param subcommands - Array of subcommands to validate
* @throws Error if any subcommand is invalid or if there are duplicate names
*/
export declare function validateSubcommands(subcommands: BotSubcommand[]): void;
/**
* Get faction color for Discord embeds
*/
export declare function getFactionColor(factionName?: string): number;
/**
* Render search result as Discord embed
*/
export declare function renderSearchResultAsEmbed(searchResult: any, query: string): {
embeds: any[];
};
/**
* Render match response as Discord embed
*/
export declare function renderMatchResponseAsEmbed(result: any, generationTime: number): {
embeds: any[];
};
//# sourceMappingURL=utils.d.ts.map