UNPKG

@wilcosp/rex

Version:

Rex is an automated command manager for discord js

95 lines (94 loc) 3.83 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 { APIButtonComponentWithCustomId, ButtonStyle } from "discord-api-types/v10"; import { ButtonInteraction, ButtonBuilder, InteractionButtonComponentData, JSONEncodable } from "discord.js"; import { RexButtonInteraction } from "../interactions/components/button.js"; import { rexExecuteFunComponentModal } from "../types/types.js"; type buttonType = InteractionButtonComponentData | APIButtonComponentWithCustomId; /** * creates a reusable button that can be used for when you use the same button for command output */ export declare class RexButtonComponent extends ButtonBuilder { private execute?; private autoDefer?; private deferEphemeral; private debounceDelay?; private auditDelay?; private useFailover?; constructor(customId: string); constructor(data: Partial<buttonType> & ({ custom_id: string; } | { customId: string; })); get customId(): string; /** * turns this button into an useable js object * @returns {APIButtonComponentWithCustomId} */ toJSON(): APIButtonComponentWithCustomId; /** * Set style of the button * @param style button style except link style * @returns button */ setStyle(style: Exclude<ButtonStyle, ButtonStyle.Link>): this; /** * set the function that will be executed with each interaction for this button * @param fun the function * @returns this */ setExecute(fun: rexExecuteFunComponentModal<RexButtonInteraction>): this; /** * auto defer 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 */ run(inter: ButtonInteraction): unknown; /** * @deprecated not available in RexButtonComponent * @returns * @ignore not supported */ setURL(): this; url: null; /** * Copy this button for cases where you want to use the same button but dynamic options * @requires executeFunction to be set with .setExecute before copy! */ copy(): RexButtonComponent; /** * create a button from an existing button without the extra features from RexButtonComponent compared to a normal discord.js button * @param other * @returns */ static from(other: JSONEncodable<APIButtonComponentWithCustomId> | APIButtonComponentWithCustomId): RexButtonComponent; } export {};