mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat(InteractionResponses): add message parameter (#8773)
This commit is contained in:
@@ -122,49 +122,56 @@ class InteractionResponses {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the initial reply to this interaction.
|
||||
* Fetches a reply to this interaction.
|
||||
* @see Webhook#fetchMessage
|
||||
* @param {Snowflake|'@original'} [message='@original'] The response to fetch
|
||||
* @returns {Promise<Message>}
|
||||
* @example
|
||||
* // Fetch the reply to this interaction
|
||||
* // Fetch the initial reply to this interaction
|
||||
* interaction.fetchReply()
|
||||
* .then(reply => console.log(`Replied with ${reply.content}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchReply() {
|
||||
return this.webhook.fetchMessage('@original');
|
||||
fetchReply(message = '@original') {
|
||||
return this.webhook.fetchMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the initial reply to this interaction.
|
||||
* @typedef {WebhookEditMessageOptions} InteractionEditReplyOptions
|
||||
* @property {MessageResolvable|'@original'} [message='@original'] The response to edit
|
||||
*/
|
||||
|
||||
/**
|
||||
* Edits a reply to this interaction.
|
||||
* @see Webhook#editMessage
|
||||
* @param {string|MessagePayload|WebhookEditMessageOptions} options The new options for the message
|
||||
* @param {string|MessagePayload|InteractionEditReplyOptions} options The new options for the message
|
||||
* @returns {Promise<Message>}
|
||||
* @example
|
||||
* // Edit the reply to this interaction
|
||||
* // Edit the initial reply to this interaction
|
||||
* interaction.editReply('New content')
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async editReply(options) {
|
||||
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
||||
const message = await this.webhook.editMessage('@original', options);
|
||||
const msg = await this.webhook.editMessage(options.message ?? '@original', options);
|
||||
this.replied = true;
|
||||
return message;
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the initial reply to this interaction.
|
||||
* Deletes a reply to this interaction.
|
||||
* @see Webhook#deleteMessage
|
||||
* @param {MessageResolvable|'@original'} [message='@original'] The response to delete
|
||||
* @returns {Promise<void>}
|
||||
* @example
|
||||
* // Delete the reply to this interaction
|
||||
* // Delete the initial reply to this interaction
|
||||
* interaction.deleteReply()
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async deleteReply() {
|
||||
await this.webhook.deleteMessage('@original');
|
||||
async deleteReply(message = '@original') {
|
||||
await this.webhook.deleteMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
22
packages/discord.js/typings/index.d.ts
vendored
22
packages/discord.js/typings/index.d.ts
vendored
@@ -439,11 +439,11 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
|
||||
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||
): Promise<Message<BooleanCache<Cached>>>;
|
||||
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||
public deleteReply(): Promise<void>;
|
||||
public deleteReply(message?: MessageResolvable | '@original'): Promise<void>;
|
||||
public editReply(
|
||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
||||
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||
): Promise<Message<BooleanCache<Cached>>>;
|
||||
public fetchReply(): Promise<Message<BooleanCache<Cached>>>;
|
||||
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
||||
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||
public reply(
|
||||
@@ -1830,11 +1830,11 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
||||
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
||||
): Promise<Message<BooleanCache<Cached>>>;
|
||||
public deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||
public deleteReply(): Promise<void>;
|
||||
public deleteReply(message?: MessageResolvable | '@original'): Promise<void>;
|
||||
public editReply(
|
||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
||||
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||
): Promise<Message<BooleanCache<Cached>>>;
|
||||
public fetchReply(): Promise<Message<BooleanCache<Cached>>>;
|
||||
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
||||
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||
public reply(
|
||||
@@ -2020,15 +2020,15 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
|
||||
public reply(
|
||||
options: string | MessagePayload | InteractionReplyOptions,
|
||||
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||
public deleteReply(): Promise<void>;
|
||||
public deleteReply(message?: MessageResolvable | '@original'): Promise<void>;
|
||||
public editReply(
|
||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
||||
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||
): Promise<Message<BooleanCache<Cached>>>;
|
||||
public deferReply(
|
||||
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||
): Promise<Message<BooleanCache<Cached>>>;
|
||||
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||
public fetchReply(): Promise<Message<BooleanCache<Cached>>>;
|
||||
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
||||
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||
public deferUpdate(
|
||||
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
||||
@@ -5758,6 +5758,10 @@ export interface WebhookEditMessageOptions extends Omit<MessageEditOptions, 'fla
|
||||
threadId?: Snowflake;
|
||||
}
|
||||
|
||||
export interface InteractionEditReplyOptions extends WebhookEditMessageOptions {
|
||||
message?: MessageResolvable | '@original';
|
||||
}
|
||||
|
||||
export interface WebhookFetchMessageOptions {
|
||||
threadId?: Snowflake;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user