Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(InteractionResponses): add message parameter #8773

Merged
merged 10 commits into from Oct 31, 2022
Expand Up @@ -136,21 +136,22 @@ class InteractionResponses {
}

/**
* Edits the initial reply to this interaction.
* Edits a reply to this interaction.
* @see Webhook#editMessage
* @param {string|MessagePayload|WebhookEditMessageOptions} options The new options for the message
* @param {MessageResolvable|"@original"} [message="@original"] The response to edit
* @returns {Promise<Message>}
* @example
* // Edit the reply to this interaction
* // Edit the initial reply to this interaction
MrMythicalYT marked this conversation as resolved.
Show resolved Hide resolved
* interaction.editReply('New content')
* .then(console.log)
* .catch(console.error);
*/
async editReply(options) {
async editReply(options, message = '@original') {
MrMythicalYT marked this conversation as resolved.
Show resolved Hide resolved
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
const message = await this.webhook.editMessage('@original', options);
const msg = await this.webhook.editMessage(message, options);
this.replied = true;
return message;
return msg;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -442,6 +442,7 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
public deleteReply(): Promise<void>;
public editReply(
options: string | MessagePayload | WebhookEditMessageOptions,
message?: MessageResolvable | '@original',
): Promise<Message<BooleanCache<Cached>>>;
public fetchReply(): Promise<Message<BooleanCache<Cached>>>;
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
Expand Down Expand Up @@ -1832,6 +1833,7 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
public deleteReply(): Promise<void>;
public editReply(
options: string | MessagePayload | WebhookEditMessageOptions,
message?: MessageResolvable | '@original',
): Promise<Message<BooleanCache<Cached>>>;
public fetchReply(): Promise<Message<BooleanCache<Cached>>>;
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
Expand Down Expand Up @@ -2022,6 +2024,7 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
public deleteReply(): Promise<void>;
public editReply(
options: string | MessagePayload | WebhookEditMessageOptions,
message?: MessageResolvable | '@original',
): Promise<Message<BooleanCache<Cached>>>;
public deferReply(
options: InteractionDeferReplyOptions & { fetchReply: true },
Expand Down