UNPKG

@confis/discordapiwrapper

Version:

A fast and lightweight discord api wrapper.

180 lines (179 loc) 6.67 kB
import { ApplicationCommandTypes, InteractionContextTypes, InteractionIntegrationTypes } from "../client"; interface choice<T> { name: T; value: T; } /** Slash command builder */ export declare class SlashCommandBuilder { name: string; description: string; private options; type: ApplicationCommandTypes; contexts: InteractionContextTypes[]; interactionIntegrationTypes: InteractionIntegrationTypes[]; private addSlashCommandOption; /** * Set the name of the slash command * @param name Name of the command * @returns SlashCommandBuilder Object */ setName(name: string): this; /** * Set to context Interaction * @param type Type of context */ setContextInteraction(type: "USER" | "MESSAGE"): this; /** * Sets the contexts in which this slash command can be used. * * @param contexts - Array of interaction context types (GUILD, DM, or GROUP_DM) * @throws {AssertionError} If array is empty or has more than 3 contexts * @returns The current SlashCommandBuilder instance for method chaining * * @example * ```typescript * SlashCommandBuilder().setContexts([ * InteractionContextTypes.GUILD, * InteractionContextTypes.DM * ]); * ``` */ setContexts(contexts: InteractionContextTypes[]): this; /** * Sets the integration types that can use this slash command. * * @param types - Array of interaction integration types (GUILD_INSTALL or USER_INSTALL) * @throws {AssertionError} If array is empty or has more than 2 types * @returns The current SlashCommandBuilder instance for method chaining * * @example * ```typescript * SlashCommandBuilder().setInteractionIntegrationTypes([ * InteractionIntegrationTypes.GUILD_INSTALL * ]); * ``` */ setInteractionIntegrationTypes(types: InteractionIntegrationTypes[]): this; /** * Set the description of the slash comamnd * @param desc Description of the command * @returns SlashCommandBuilder Object */ setDescription(desc: string): this; /** * Add an integer option to the slash command * @param name Name of the option * @param description Description of the option * @param required * @param choices If the option is required or not * @returns SlashCommandBuilder Object */ addNumberOption(name: string, description: string, required?: boolean, choices?: choice<number>[]): this; /** * Add a string option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addStringOption(name: string, description: string, required?: boolean, choices?: choice<string>[]): this; /** * Add a boolean option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addBooleanOption(name: string, description: string, required?: boolean): this; /** * Add a user option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addUserOption(name: string, description: string, required?: boolean): this; /** * Add an attachment option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addAttachmentOption(name: string, description: string, required?: boolean): this; toJson(): any; addSubCommand(data: SubCommandBuilder): this; /** * Create a sub command group with sub commands * * @param name The name of the sub command group * @param description The description of the sub command group * @param subCommands An array of sub commands * @returns */ addSubCommandGroup(name: string, description: string, ...subCommands: SubCommandBuilder[]): this; } /** Sub Command builder */ export declare class SubCommandBuilder { private name; private description; private options; private addSlashCommandOption; /** * Set the name of the sub command * * @param name Name of the sub command * @returns SubCommandBuilder object */ setName(name: string): this; /** * Set the description of the sub command * * @param description Description of the sub command * @returns SubCommandBuilder object */ setDescription(description: string): this; /** * Add an integer option to the slash command * @param name Name of the option * @param description Description of the option * @param required * @param choices If the option is required or not * @returns SlashCommandBuilder Object */ addNumberOption(name: string, description: string, required?: boolean, choices?: choice<number>[]): this; /** * Add a string option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addStringOption(name: string, description: string, required?: boolean, choices?: choice<string>[]): this; /** * Add a boolean option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addBooleanOption(name: string, description: string, required?: boolean): this; /** * Add a user option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addUserOption(name: string, description: string, required?: boolean): this; /** * Add an attachment option to the slash command * @param name Name of the option * @param description Description of the option * @param required If the option is required or not * @returns SlashCommandBuilder Object */ addAttachmentOption(name: string, description: string, required?: boolean): this; toJson(): any; } export {};