@discord-additions/components
Version:
Some helpful additions to make creating components easier.
76 lines (75 loc) • 3.41 kB
TypeScript
import Component from "./Component";
import { ComponentTypes } from "../util/Constants";
import type { PartialEmoji, SelectMenuOption, SelectMenu as ISelectMenu } from "../util/types";
export default class SelectMenu extends Component<typeof ComponentTypes["SELECT_MENU"]> {
customID: string;
options: Array<SelectMenuOption>;
placeholder?: string;
minValues?: number;
maxValues?: number;
disabled: boolean;
/**
* Create a new SelectMenu
*
* @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure
* @param {string} customID - the custom id of this select menu
*/
constructor(customID: string);
/**
* Set the custom_id of this select menu.
*
* @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure
* @param {string} customID - a developer-defined identifier for the button, max 100 characters
* @returns {SelectMenu}
*/
setCustomID(customID: string): this;
/**
* Set the placeholder of this select menu.
*
* @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure
* @param {string} placeholder - custom placeholder text if nothing is selected, max 100 characters
* @returns {SelectMenu}
*/
setPlaceholder(placeholder: string): this;
/**
* Set the minimum/maximum values of this select menu.
*
* @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure
* @param {number} [min] - the minimum selected values
* @param {number} [max] - the maximum selected values
* @returns {SelectMenu}
*/
setValues(min?: number, max?: number): this;
/**
* Add an option to this select menu
*
* @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
* @param {string} label
* @param {string} value
* @param {string} [description]
* @param {object} [emoji] - the emoji to displayed with this option
* @param {(string | null)} [emoji.id] - the id of this emoji, null if built in
* @param {string} [emoji.name] - the name of this emoji, unicode if built in
* @param {boolean} [emoji.animated] - if the emoji is animated
* @param {boolean} [defaultSelection] - if this option should be the default selected option
* @returns {SelectMenu}
*/
addOption(label: string, value: string, description?: string, emoji?: PartialEmoji, defaultSelection?: boolean): this;
/**
* Add options to this select menu in bulk
*
* @param {Array<SelectMenuOption>} options - the options to add
* @returns {SelectMenu}
*/
addOptions(...options: Array<SelectMenuOption>): this;
/**
* Clear all currently present options on this select menu.
*
* @returns {SelectMenu}
*/
clearOptions(): this;
/** this method is meant to be for internal use only, don't use it, as it may break or change at a moments notice */
load(customID?: string, options?: Array<SelectMenuOption>, placeholder?: string, minValues?: number, maxValues?: number, disabled?: boolean): this;
/** converts this SelectMenu instance to raw json */
toJSON(): ISelectMenu;
}