mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +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
|
* @see Webhook#fetchMessage
|
||||||
|
* @param {Snowflake|'@original'} [message='@original'] The response to fetch
|
||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
* @example
|
* @example
|
||||||
* // Fetch the reply to this interaction
|
* // Fetch the initial reply to this interaction
|
||||||
* interaction.fetchReply()
|
* interaction.fetchReply()
|
||||||
* .then(reply => console.log(`Replied with ${reply.content}`))
|
* .then(reply => console.log(`Replied with ${reply.content}`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
fetchReply() {
|
fetchReply(message = '@original') {
|
||||||
return this.webhook.fetchMessage('@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
|
* @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>}
|
* @returns {Promise<Message>}
|
||||||
* @example
|
* @example
|
||||||
* // Edit the reply to this interaction
|
* // Edit the initial reply to this interaction
|
||||||
* interaction.editReply('New content')
|
* interaction.editReply('New content')
|
||||||
* .then(console.log)
|
* .then(console.log)
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async editReply(options) {
|
async editReply(options) {
|
||||||
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
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;
|
this.replied = true;
|
||||||
return message;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the initial reply to this interaction.
|
* Deletes a reply to this interaction.
|
||||||
* @see Webhook#deleteMessage
|
* @see Webhook#deleteMessage
|
||||||
|
* @param {MessageResolvable|'@original'} [message='@original'] The response to delete
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
* @example
|
* @example
|
||||||
* // Delete the reply to this interaction
|
* // Delete the initial reply to this interaction
|
||||||
* interaction.deleteReply()
|
* interaction.deleteReply()
|
||||||
* .then(console.log)
|
* .then(console.log)
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async deleteReply() {
|
async deleteReply(message = '@original') {
|
||||||
await this.webhook.deleteMessage('@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 },
|
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||||
public deleteReply(): Promise<void>;
|
public deleteReply(message?: MessageResolvable | '@original'): Promise<void>;
|
||||||
public editReply(
|
public editReply(
|
||||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): 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 followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(
|
public reply(
|
||||||
@@ -1830,11 +1830,11 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|||||||
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
public deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||||
public deleteReply(): Promise<void>;
|
public deleteReply(message?: MessageResolvable | '@original'): Promise<void>;
|
||||||
public editReply(
|
public editReply(
|
||||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): 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 followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(
|
public reply(
|
||||||
@@ -2020,15 +2020,15 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
|
|||||||
public reply(
|
public reply(
|
||||||
options: string | MessagePayload | InteractionReplyOptions,
|
options: string | MessagePayload | InteractionReplyOptions,
|
||||||
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||||
public deleteReply(): Promise<void>;
|
public deleteReply(message?: MessageResolvable | '@original'): Promise<void>;
|
||||||
public editReply(
|
public editReply(
|
||||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferReply(
|
public deferReply(
|
||||||
options: InteractionDeferReplyOptions & { fetchReply: true },
|
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<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 followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferUpdate(
|
public deferUpdate(
|
||||||
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
||||||
@@ -5758,6 +5758,10 @@ export interface WebhookEditMessageOptions extends Omit<MessageEditOptions, 'fla
|
|||||||
threadId?: Snowflake;
|
threadId?: Snowflake;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InteractionEditReplyOptions extends WebhookEditMessageOptions {
|
||||||
|
message?: MessageResolvable | '@original';
|
||||||
|
}
|
||||||
|
|
||||||
export interface WebhookFetchMessageOptions {
|
export interface WebhookFetchMessageOptions {
|
||||||
threadId?: Snowflake;
|
threadId?: Snowflake;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user