feat(InteractionResponses): add message parameter (v13) (#8838)

Co-authored-by: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com>
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Jaworek
2022-11-25 18:19:25 +01:00
committed by GitHub
parent eecc50bfda
commit 0e0851aa18
2 changed files with 35 additions and 24 deletions

View File

@@ -114,50 +114,58 @@ class InteractionResponses {
}
/**
* Fetches the initial reply to this interaction.
* Fetches a reply to this interaction.
* @see Webhook#fetchMessage
* @param {MessageResolvable|'@original'} [message='@original'] The response to fetch
* @returns {Promise<Message|APIMessage>}
* @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.
* Options that can be passed into {@link InteractionResponses#editReply}.
* @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|APIMessage>}
* @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 Error('INTERACTION_NOT_REPLIED');
const message = await this.webhook.editMessage('@original', options);
const message = await this.webhook.editMessage(options.messsage ?? '@original', options);
this.replied = true;
return message;
}
/**
* 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() {
async deleteReply(message = '@original') {
if (this.ephemeral) throw new Error('INTERACTION_EPHEMERAL_REPLIED');
await this.webhook.deleteMessage('@original');
await this.webhook.deleteMessage(message);
}
/**