UNPKG

@wilcosp/rex

Version:

Rex is an automated command manager for discord js

74 lines (73 loc) 3.15 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 { APIModalInteractionResponseCallbackData } from "discord-api-types/v10.js"; import { ModalComponentData, ModalSubmitInteraction } from "discord.js"; import { RexModalSubmitInteraction } from "../interactions/modal/modalSubmit.js"; import { RexModal } from "./modal.js"; type executeFun = (inter: RexModalSubmitInteraction) => void | unknown; export declare class RexModalExecute extends RexModal { private execute?; private autoDefer?; private deferEphemeral; private debounceDelay?; private auditDelay?; private useFailover?; /** * Create a modal that can be used in response in interaction that you want to use multiple times * @param customId custom ID for this modal */ constructor(customId: string, title: string); /** * Create a modal that can be used in response in interaction that you want to use multiple times * @param options modelOptions */ constructor(options: Partial<ModalComponentData | APIModalInteractionResponseCallbackData>); /** * set the execute function of this modal * @param fun executable function * @returns this */ setExecute(fun: executeFun): 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 automaticly 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 orcurred * @param value wether you want to use the fail over * @returns this */ setUseFailOver(value: boolean): this; /** * * @param inter the interaction * @ignore internal only */ run(inter: ModalSubmitInteraction): unknown; toJSON(): APIModalInteractionResponseCallbackData; /** * Copy this modal for cases where you want to use the same modal but dynamic options * @requires executeFunction to be set with .setExecute before copy! */ copy(): RexModalExecute; } export {};