UNPKG

@wilcosp/rex

Version:

Rex is an automated command manager for discord js

59 lines (58 loc) 3.2 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 { APIChannelSelectComponent, APIMentionableSelectComponent, APIRoleSelectComponent, APIUserSelectComponent, ComponentType } from "discord-api-types/v10"; import { BaseSelectMenuBuilder } from "discord.js"; import { RexSelectMenuInteractionBase } from "../interactions/components/selectmenu.js"; import { ExtraCommandReplyInteractionOptions, rexExecuteFunComponentModal, SelectMenuInteraction } from "../types/types"; export type selectMenuTypes = ComponentType.ChannelSelect | ComponentType.MentionableSelect | ComponentType.RoleSelect | ComponentType.UserSelect; export type selectTypes = APIUserSelectComponent | APIRoleSelectComponent | APIMentionableSelectComponent | APIChannelSelectComponent; export declare abstract class RexSelectMenuBase<SMT extends selectTypes, INTER extends RexSelectMenuInteractionBase, IN extends SelectMenuInteraction> extends BaseSelectMenuBuilder<SMT> { protected execute?: rexExecuteFunComponentModal<INTER>; protected autoDefer?: boolean; protected deferEphemeral: boolean; protected debounceDelay?: number; protected auditDelay?: number; protected useFailover?: boolean; constructor(data: string | Omit<SMT, "type">, type: selectMenuTypes); get customId(): SMT["custom_id"] | undefined; /** * 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; /** * set the execute function of this selectmenu * @param fun The function that will handle the interaction * @returns this */ setExecute(fun: rexExecuteFunComponentModal<INTER>): this; /** * @ignore internal only */ run(inter: IN, use: new (inter: IN, extra: ExtraCommandReplyInteractionOptions) => INTER): unknown; toJSON(): SMT; }