UNPKG

@wilcosp/rex

Version:

Rex is an automated command manager for discord js

112 lines (111 loc) 4.55 kB
/*! * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { APIStringSelectComponent } from "discord-api-types/v10"; import { JSONEncodable, StringSelectMenuBuilder, StringSelectMenuComponentData, StringSelectMenuInteraction } from "discord.js"; import { RexSelectMenuInteractionBase } from "../interactions/components/selectmenu.js"; import { RexArray, rexExecuteFunComponentModal } from "../types/types.js"; type selectMenuType = APIStringSelectComponent | StringSelectMenuComponentData; /** * creates a reusable select menu that can be used for when you use the same select menu for command output */ export declare class RexStringSelectMenuComponent extends StringSelectMenuBuilder { private execute?; private autoDefer?; private deferEphemeral; private debounceDelay?; private auditDelay?; private useFailover?; /** * Create a string based select menu with only a custom id * @param customId the custom id */ constructor(customId: string); /** * Create a string based select menu with raw string select menu data * @param data string select menu data */ constructor(data: Omit<selectMenuType, "type"> & ({ custom_id: string; } | { customId: string; })); get customId(): string | undefined; /** * turn the string select menu into useable json * @returns {APIStringSelectComponent} */ toJSON(): APIStringSelectComponent; /** * set the execute function of this selectmenu * @param fun The function that will handle the interaction * @returns this */ setExecute(fun: rexExecuteFunComponentModal<RexSelectMenuInteractionBase>): this; /** * auto defers a message when there hasn't been an reply within 2.5 seconds minus ping * (does not work for autocomplete) * make sure to not use interaction.reply * @param defer whether there should be automatically be deferred when not responding within 2.5 seconds * @param ephemeral whether the auto defer should be ephemeral or not (by default false) */ setAutoDefer(defer: boolean, ephemeral?: boolean): this; /** * set the delay in milliseconds for how long a debounce should last, if not set then it will be 1 second * @param delay delay in milliseconds */ setDebounceDelay(delay: number): this; /** * set the delay in milliseconds for how long an audit should last, if not set it will be by default 1 second. * @param delay delay in seconds * @description an audit is similar to throttle but sends the most recent edit/update attempt instead of the next attempt * @see https://rxjs.dev/api/index/function/audit for a visual example for how audit works */ setAuditDelay(delay: number): this; /** * Set if the message.edit route should be used if the interaction has expired or a rate limited had occurred * @param value wether you want to use the fail over * @returns this */ setUseFailOver(value: boolean): this; /** * @ignore internal only */ run(inter: StringSelectMenuInteraction): unknown; /** * same as addOptions but normalized * @param options the options you want the user to have a choice of (max 25!) * @returns this */ addOptionsNormalized(...options: RexArray<{ toString(): string; } | string>): this; /** * same as setOptions but normalized * @param options the options you want the user to have a choice of (max 25!) * @returns this */ setOptionsNormalized(...options: RexArray<{ toString(): string; } | string>): this; /** * Copy this select menu for cases where you want to use the same select menu but dynamic options * @requires executeFunction to be set with .setExecute before copy! */ copy(): RexStringSelectMenuComponent; /** * create a button from an existing button without the extra features from RexButtonComponent compared to a normal discord.js button * @param other */ static from(other: JSONEncodable<APIStringSelectComponent> | APIStringSelectComponent): RexStringSelectMenuComponent; } /** * backwards compatibility for deprecation period * @extends RexStringSelectMenuComponent * @deprecated */ export declare class RexSelectMenuComponent extends RexStringSelectMenuComponent { } export {};