@wilcosp/rex
Version:
Rex is an automated command manager for discord js
188 lines (187 loc) • 10.3 kB
TypeScript
/*!
* 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 { APIMessage, Snowflake } from "discord-api-types/v10";
import { CacheType, CommandInteraction, ContextMenuCommandInteraction, GuildCacheMessage, InteractionDeferReplyOptions, InteractionReplyOptions, InteractionResponse, Message, MessageComponentInteraction, MessagePayload, MessageResolvable, ModalSubmitInteraction, WebhookEditMessageOptions } from "discord.js";
import { ExtraCommandReplyInteractionOptions } from "../types/types.js";
import { RexInteractionBase } from "./interactionBase.js";
declare const OG_MSG: "@original";
type interactions = CommandInteraction | ContextMenuCommandInteraction | MessageComponentInteraction | ModalSubmitInteraction;
export declare class RexReplyInteractionBase extends RexInteractionBase {
inter: interactions;
private deferEphemeral?;
private lastMessage?;
private lastRequest;
protected debounceDelay: number;
private debounceMap?;
protected auditDelay: number;
private auditMap?;
private useFailOver?;
private _response?;
private responseId?;
constructor(inter: interactions, { autoDefer, deferEphemeral, debounceDelay, auditDelay, useFailOver }?: ExtraCommandReplyInteractionOptions);
get deferred(): boolean;
get ephemeral(): boolean | null;
get replied(): boolean;
get webhook(): import("discord.js").InteractionWebhook;
/**
* The initial response to the interaction if fetchreply or usefailsave was used
*/
get response(): Message<boolean> | undefined;
/**
* reply to the interaction
* @param options options for the reply
* @returns the reply message
*/
reply(options: InteractionReplyOptions & {
fetchReply: true;
}): Promise<Message<boolean>>;
/**
* reply to the interaction
* @param options options for the reply
*/
reply(options: string | MessagePayload | InteractionReplyOptions): Promise<InteractionResponse<boolean>>;
/**
* defer replying to the interaction
* @param options options for the defer
* @returns the defer message
*/
deferReply(options: InteractionDeferReplyOptions & {
fetchReply: true;
}): Promise<Message>;
/**
* defer replying to the interaction
* @param options options for the defer
*/
deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<boolean>>;
/**
* delete the reply to this interaction
*/
deleteReply(): Promise<void | Message<boolean>>;
/**
* edit the original reply to the interaction
* @param options options to edit the reply to the interaction
*/
editReply(options: string | MessagePayload | WebhookEditMessageOptions): Promise<Message<boolean>>;
/**
* edit the first reply but have it debounced when trying to edit many times in a short amount of time
* @param options options to edit the message with
* @returns the edited message, if edit gets debounced then the earlier edits attempts will return nothing
* @description debounce delays attempts for editing/updating messages, when a new edit/update attempt is tried then the delay is reset and the previous attempt is dropped
* @see https://rxjs.dev/api/index/function/debounce for a visual example for how debounce works
*/
editReplyDebounce(options: string | MessagePayload | WebhookEditMessageOptions): Promise<Message<boolean> | void | undefined>;
/**
* edit the first reply by using audit when trying to edit many times in a short amount of time
* @param options options to edit the message with
* @returns if attempt was success it will return the edited message, if attempt is dropped it will return nothing
* @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
*/
editReplyAudit(options: string | MessagePayload | WebhookEditMessageOptions): Promise<GuildCacheMessage<CacheType> | void | undefined>;
/**
* fetch the original reply to the interaction
* @returns original reply
*/
fetchReply(): Promise<Message<boolean>>;
fetchMessage(id: Snowflake): Promise<Message>;
/**
* Send a follow-up message to this interaction.
* @param options options for the follow up reply
*/
followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<boolean>>;
/**
* Reply to an interaction but if there is already replied then edit the message
* @param options the normal options for either Reply or edit
* @retuns the new/edited message
*/
replyOrEdit(options: InteractionReplyOptions & {
fetchReply: true;
}): Promise<Message<boolean> | APIMessage>;
/**
* Reply to an interaction but if there is already replied then edit the message
* @param options the normal options for either Reply or edit
* @retuns when editing the message the edited message, else nothing
*/
replyOrEdit(options: string | MessagePayload | InteractionReplyOptions): Promise<InteractionResponse<boolean> | APIMessage | Message<boolean>>;
/**
* Reply to an interaction but if already replied then edit the message by using debouncing
* @param options the normal options for either Reply or edit
* @returns when editing a meessage or fetchReply = true will return the message, if this attempt is dropped or fetchReply = false then nothing
* @description debounce delays attempts for editing/updating messages, when a new edit/update attempt is tried then the delay is reset and the previous attempt is dropped
* @see https://rxjs.dev/api/index/function/debounce for an visual example for how debounce works
*/
replyOrEditDebounce(options: string | MessagePayload | InteractionReplyOptions): Promise<void | undefined | InteractionResponse<boolean> | GuildCacheMessage<CacheType>>;
/**
* Reply to an interaction but if already replied then edit the message by using auditing
* @param options the normal options for either Reply or edit
* @returns when editing a meessage or fetchReply = true will return the message, if this attempt is dropped or fetchReply = false then nothing
* @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
*/
replyOrEditAudit(options: string | MessagePayload | InteractionReplyOptions): Promise<InteractionResponse<boolean> | GuildCacheMessage<CacheType> | void>;
/**
* Reply to an interaction or follow up if there is already replied (deferred will get edited)
* @param options the normal options for either Reply, followup or edit
* @returns the new message
*/
replyOrFollowUp(options: InteractionReplyOptions & {
fetchReply: true;
}): Promise<GuildCacheMessage<CacheType>>;
/**
* Reply to an interaction or follow up if there is already replied (deferred will get edited)
* @param options the normal options for either Reply, followup or edit
* @returns if following up the new message, when replying then nothing
*/
replyOrFollowUp(options: string | MessagePayload | InteractionReplyOptions): Promise<void | GuildCacheMessage<CacheType> | InteractionResponse<boolean>>;
/**
* edit a message from the interaction
* @param options options to edit the message with
* @param message message to edit, if not given it will edit last followup/reply
* @returns (api) Message
*/
editMessage(options: string | MessagePayload | WebhookEditMessageOptions, message?: Snowflake | Message | APIMessage | typeof OG_MSG): Promise<void | GuildCacheMessage<CacheType>>;
/**
* edit a message from the interaction
* @param options options to edit the message with
* @param message message to edit, if not given it will edit last followup/reply
* @returns if attempt is succesfull it will return the edited message, if dropped then nothing
* @description debounce delays attempts for editing/updating messages, when a new edit/update attempt is tried then the delay is reset and the previous attempt is dropped
* @see https://rxjs.dev/api/index/function/debounce for a visual example for how debounce works
*/
editMessageDebounce(options: string | MessagePayload | WebhookEditMessageOptions, message?: Snowflake | Message | APIMessage | typeof OG_MSG): Promise<void | undefined | GuildCacheMessage<CacheType>>;
/**
* edit a message from the interaction
* @param options options to edit the message with
* @param message message to edit, if not given it will edit last followup/reply
* @returns if attempt is succesfull it will return the edited message, if dropped then nothing
* @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
*/
editMessageAudit(options: string | MessagePayload | WebhookEditMessageOptions, message?: Snowflake | Message | APIMessage | typeof OG_MSG): Promise<void | undefined | GuildCacheMessage<CacheType>>;
/**
* delete message
* @param message the message you want to remove, if none is given then the last message/reply will be deleted
* @returns void
*/
deleteMessage(message?: MessageResolvable | APIMessage | typeof OG_MSG): Promise<void | Message<boolean>>;
/**
* change if the auto defer should be Ephemeral or not
* @param ephemeral {boolean}
*/
setDeferEphemeral(ephemeral: boolean): void;
/**
* executes the automatic defer
* @ignore
*/
private autoDefer;
/**
* @ignore only for Rex
*/
protected asignLastRequest<T>(value: Promise<T>): Promise<T>;
private fetchChannelMessage;
private editChannelMessage;
}
export {};