UNPKG

@confis/discordapiwrapper

Version:

A fast and lightweight discord api wrapper.

378 lines (377 loc) 10.3 kB
import { ButtonStyles, JSONCache, PartialEmoji } from "../client"; type SUPPORTED_ELEMENTS = ButtonBuilder | StringSelectMenuBuilder | TextInputBuilder; export interface FieldOptions { name: string; value: string; inline?: boolean; } export interface FooterOptions { text: string; icon_url?: string; proxy_icon_url?: string; } export interface ImageOptions { url: string; height?: number; width?: number; } export interface AuthorOptions { name: string; url?: string; icon_url: string; proxy_icon_url?: string; } /** Embed builder */ export declare class EmbedBuilder { private author?; private color?; private description?; private fields?; private footer?; private image?; private thumbnail?; private timestamp?; private title?; private url?; /** * Set the author of the embed * @param options Author Options * @returns EmbedBuilder Object */ setAuthor(options: AuthorOptions): this; /** * Set the timestamp of the embed * @param date The timestamp date * @returns EmbedBuilder Object */ setTimestamp(date?: Date): this; /** * Set the title of the embed * @param title The title of the embed * @returns EmbedBuilder Object */ setTitle(title: string): this; /** * Set the Color of the embed * @param color The color of the embed in decial or hex * @returns EmbedBuilder Object */ setColor(color: string | number): this; /** * Set the Description of the embed * @param description The description of the embed * @returns EmbedBuilder Object */ setDescription(description: string): this; /** * Set the Thumbnail of the embed * @param options {@link ImageOptions} * @returns EmbedBuilder Object */ setThumbnail(options: ImageOptions): this; /** * Set the Image of the embed * @param options {@link ImageOptions} * @returns EmbedBuilder Object */ setImage(options: ImageOptions): this; /** * Set the Footer of the embed * @param options {@link FooterOptions} * @returns EmbedBuilder Object */ setFooter(options: FooterOptions): this; /** * Set the Fields of the embed * @param fields {@link FieldOptions} * @returns EmbedBuilder Object */ setFields(fields: FieldOptions[]): this; /** * Add one or more fields to the embed * @param fields The fields to add * @returns EmbedBuilder Object */ addFields(...fields: FieldOptions[]): this; /** * Set the URL of the embed * @param url The URL * @returns EmbedBuilder Object */ setURL(url: string): this; toJson(): { author: AuthorOptions; color: number; description: string; fields: FieldOptions[]; footer: FooterOptions; image: ImageOptions; thumbnail: ImageOptions; timestamp: string | Date; title: string; url: string; }; } /** Button builder */ export declare class ButtonBuilder { #private; /** * Set the URL of the button * @param url the URL * @returns ButtonBuilder Object */ setUrl(url: string): this; /** * Set the Label of the button * @param label the Label * @returns ButtonBuilder Object */ setLabel(label: string): this; /** * Set the Style of the button * @param style {@link ButtonStyles} * @returns ButtonBuilder Object */ setStyle(style: ButtonStyles): this; /** * Set the Custom ID of the button * @param id The custom ID * @returns ButtonBuilder Object */ setCustomID(id: string): this; /** * Set if the button is disabled * @param disabled Disabled field * @returns ButtonBuilder Object */ setDisabled(disabled: boolean): this; /** * Set the emoji of the button * @param emoji The emoji * @returns ButtonBuilder Object */ setEmoji(emoji: string): this; toJson(): { type: number; label: string; style: number; custom_id: string; disabled: boolean; emoji: Partial<PartialEmoji>; url: string; }; } /** String select menu builder */ export declare class StringSelectMenuBuilder { #private; options: StringSelect[]; /** * Set the Placeholder of the StringSelectMenu * @param placeholder The placeholder * @returns StringSelectMenuBuilder Object */ setPlaceholder(placeholder: string): this; /** * Set the Custom ID of the StringSelectMenu * @param id The custom ID * @returns StringSelectMenuBuilder Object */ setCustomID(id: string): this; /** * Set if the menu is disabled * @param disabled Disabled field * @returns StringSelectMenuBuilder Object */ setDisabled(disabled: boolean): this; /** * Set the options of the StringSelectMenu * @param ...args An array of {@link StringSelect} * @returns StringSelectMenuBuilder Object */ setOptions(...args: StringSelect[]): this; toJson(): { type: number; custom_id: string; options: JSONCache[]; placeholder: string; disabled: boolean; }; } /** String select object */ export declare class StringSelect { #private; /** * Set the Label of the StringSelect * @param label The label * @returns StringSelect Object */ setLabel(label: string): this; /** * Set the Value of the StringSelect * @param value The value * @returns StringSelect Object */ setValue(value: string): this; /** * Set the Description of the StringSelect * @param description The description * @returns StringSelect Object */ setDescription(description: string): this; /** * Set the Emoji of the StringSelect * @param emoji The emoji * @returns StringSelect Object */ setEmoji(emoji: string): this; /** * Set if the string select is default * @param value Default value * @returns StringSelect Object */ setDefault(value: boolean): this; toJson(): { label: string; value: string; description: string; emoji: Partial<PartialEmoji>; default: boolean; }; } /** Action Row builder */ export declare class ActionRowBuilder<T extends SUPPORTED_ELEMENTS> { components: Array<T>; /** * Set the Components of the ActionRow * @param ...args An array of {@link SUPPORTED_ELEMENTS} * @returns ActionRowBuilder Object */ setComponents(...args: T[]): this; /** * Add components to the ActionRow * @param args An array of components to add * @returns ActionRowBuilder Object for method chaining */ addComponents(...args: T[]): this; /** * Disables all components in the action row * @returns The ActionRowBuilder instance for method chaining */ disableAllComponents(): this; /** * Set the Components of the ActionRow * @param components An array of {@link SUPPORTED_ELEMENTS} * @returns ActionRowBuilder Object */ setComponentsArray(components: T[]): this; toJson(): { type: number; components: any[]; }; } /** Text input styles enum */ export declare enum TextInputStyles { SHORT = 1, PARAGRAPH = 2 } /** Text input builder */ export declare class TextInputBuilder { #private; /** * Set the Custom ID of the text input * @param id The custom ID * @returns TextInputBuilder Object */ setCustomID(id: string): this; /** * Set the Label of the text input * @param label The label * @returns TextInputBuilder Object */ setLabel(label: string): this; /** * Set the Style of the text input * @param style The style from TextInputStyles * @returns TextInputBuilder Object */ setStyle(style: TextInputStyles): this; /** * Set the Minimum Length of the text input * @param length The minimum length * @returns TextInputBuilder Object */ setMinLength(length: number): this; /** * Set the Maximum Length of the text input * @param length The maximum length * @returns TextInputBuilder Object */ setMaxLength(length: number): this; /** * Set if the text input is required * @param required Whether the field is required * @returns TextInputBuilder Object */ setRequired(required: boolean): this; /** * Set the Value of the text input * @param value The pre-filled value * @returns TextInputBuilder Object */ setValue(value: string): this; /** * Set the Placeholder of the text input * @param placeholder The placeholder text * @returns TextInputBuilder Object */ setPlaceholder(placeholder: string): this; toJson(): { type: number; custom_id: string; label: string; style: number; min_length?: number; max_length?: number; required: boolean; value?: string; placeholder?: string; }; } /** Modal builder */ export declare class ModalBuilder { #private; /** * Set the Title of the modal * @param title The title * @returns ModalBuilder Object */ setTitle(title: string): this; /** * Set the Custom ID of the modal * @param id The custom ID * @returns ModalBuilder Object */ setCustomID(id: string): this; /** * Add components to the modal * @param components The components to add * @returns ModalBuilder Object */ addComponents(components: ActionRowBuilder<TextInputBuilder>): this; /** * Set the components of the modal * @param components The components to set * @returns ModalBuilder Object */ setComponents(components: ActionRowBuilder<TextInputBuilder>): this; toJson(): { title: string; custom_id: string; type: number; components: { type: number; components: any[]; }[]; }; } export {};