UNPKG

@confis/discordapiwrapper

Version:

A fast and lightweight discord api wrapper.

265 lines (264 loc) 9.24 kB
import { Guild, Channel, Member, Message, User, Client, ApplicationCommandTypes, BaseData, ContentOptions, APIApplicationCommandOptionsData, ModalBuilder } from "../index"; import { Base } from "../internal/Base"; /** Interaction object */ export declare class Interaction extends Base { #private; readonly token: string; readonly callbackURL: string; readonly interactionID: string; readonly name: string; readonly id: string; readonly guildID: string; readonly description?: string; readonly type: ApplicationCommandTypes; acknowledged: boolean; constructor(data: BaseData, client: Client); /** * Get the guild of the interaction * @returns A guild object */ get guild(): Guild; /** * Get the channel of the interaction * @returns A channel object */ get channel(): Channel; /** * Get the user of the interaction * @returns A user object */ get user(): User; /** * Get the member of the interaction * @returns A member object */ get member(): Member | null; /** * Retrieves the original message sent through the webhook. * * @return {Promise<Message>} The original message as a `Message` object. * @throws {Error} If the request fails with a 400 status code. */ getOriginalMessage(): Promise<Message>; /** * Sends a reply message to the interaction. * * @param {string | ContentOptions} content - The content of the message. It can be a string or an object with optional properties like embeds, components, and file. * @param {number | undefined} deleteAfter - The number of milliseconds to wait before deleting the message. * @return {Promise<Message>} A promise that resolves to the sent message as a `Message` object. * @throws {Error} If the request fails with a 400 status code. */ reply(content: string | ContentOptions, deleteAfter?: number): Promise<Message>; sendModal(content: ModalBuilder): Promise<void>; /** * Defer the reply to an interaction. * * @param {Object} options - Optional parameters for the deferral. * @param {boolean} options.ephemeral - Whether the reply should be ephemeral. * @return {Promise<void>} - A promise that resolves when the deferral is complete. */ defer(options?: { ephemeral?: boolean; }): Promise<void>; /** * Edits the message with the given content. * * @param {string | ContentOptions} content - The content to edit the message with. It can be a string or an object with properties like content, embeds, components, ephemeral, and file. * @return {Promise<Message>} A promise that resolves to the edited message. * @throws {Error} If there is an error editing the message. */ edit(content: string | ContentOptions): Promise<Message>; /** * Sends a follow up with the given content * * @param content - The content to send a follow up with * @return {Promise<Message>} A promise that resolves to the sent message. * @throws {Error} If there is an error sending a follow up. */ followUp(content: string | ContentOptions): Promise<Message>; /** * Delete the interaction message */ delete(): Promise<void>; } /** Slash command interaction object */ export declare class SlashCommandInteraction extends Interaction { options?: APIApplicationCommandOptionsData[]; resolved?: any; constructor(data: BaseData, client: Client); /** * Returns whether the slash command has a sub command group or not. */ get hasSubCommandGroup(): boolean; /** * Returns sub command from the sub comand group */ get subCommandFromGroup(): SubCommand | undefined; /** * Returns whether the slash command has a sub command or not. */ get hasSubCommand(): boolean; /** * Returns sub command from the sub comand group */ get subCommand(): SubCommand | undefined; /** * Get the string option * @param name Name of the option * @returns Option data */ getString(name: string): APIApplicationCommandOptionsData | undefined; /** * Get the user option * @param name Name of the option * @returns Option data */ getUser(name: string): APIApplicationCommandOptionsData | undefined; /** * Get the boolean option * @param name Name of the option * @returns Option data */ getBoolean(name: string): APIApplicationCommandOptionsData | undefined; /** * Get the integer option * @param name Name of the option * @returns Option data */ getNumber(name: string): APIApplicationCommandOptionsData | undefined; /** * Get the attachment option * @param name Name of the option * @returns Option data */ getAttachment(name: string): { width: number; url: string; size: number; proxy_url: string; placeholder_version: number; placeholder: string; id: string; height: number; filename: string; ephemeral: boolean; content_type: string; }; } /** Button interaction object */ export declare class ButtonInteraction extends Interaction { #private; readonly message: Message; constructor(data: BaseData, client: Client); /** * Gets the custom ID of the button component * @returns The custom ID string that was set when creating the button */ get customID(): string; /** * Defer the interaction by sending a response with a type of 6. * * @return {Promise<void>} A promise that resolves when the defer request is successful. * @throws {Error} If the defer request returns a status of 400. */ defer(): Promise<void>; /** * Updates the content of a message with embeds, components, and files. * * @param {string | ContentOptions} content - The new content of the message or options for the message. * @return {Promise<Message>} A promise that resolves to the updated message. */ update(content: string | ContentOptions): Promise<void>; } export declare class ModalInteraction extends Interaction { readonly data: { custom_id: string; components: { type: number; data: { type: number; custom_id: string; value: string; }; }[]; }; constructor(data: BaseData, client: Client); /** * Gets the custom ID of the modal component * @returns The custom ID string that was set when creating the modal */ get customID(): string; } /** String select menu interaction */ export declare class StringSelectMenuInteraction extends Interaction { readonly data: { component_type: number; custom_id: string; values: string[]; }; constructor(data: BaseData, client: Client); /** * Gets the custom ID of the string select menu component * @returns The custom ID string that was set when creating the menu */ get customID(): string; /** * Gets the selected values from the string select menu * @returns An array of strings containing the values of the selected options */ get values(): string[]; /** * Defer the interaction by sending a response with a type of 6. * * @return {Promise<void>} A promise that resolves when the defer request is successful. * @throws {Error} If the defer request returns a status of 400. */ defer(): Promise<void>; /** * Updates the content of a message with embeds, components, and files. * * @param {string | ContentOptions} content - The new content of the message or options for the message. * @return {Promise<Message>} A promise that resolves to the updated message. */ update(content: string | ContentOptions): Promise<void>; } /** Message context interaction */ export declare class MessageContextInteraction extends Interaction { readonly target_id: string; readonly message: Message; constructor(data: BaseData, client: Client); } /** User context interaction */ export declare class UserContextInteraction extends Interaction { readonly target_id: string; readonly target: { user?: User; member?: Member; }; constructor(data: BaseData, client: Client); } /** Sub Command object */ declare class SubCommand { readonly name: string; readonly options: APIApplicationCommandOptionsData[]; constructor(data: APIApplicationCommandOptionsData); /** * Get the string option * @param name Name of the option * @returns Option data */ getString(name: string): APIApplicationCommandOptionsData | undefined; /** * Get the boolean option * @param name Name of the option * @returns Option data */ getBoolean(name: string): APIApplicationCommandOptionsData | undefined; /** * Get the integer option * @param name Name of the option * @returns Option data */ getNumber(name: string): APIApplicationCommandOptionsData | undefined; } export {};