feat(InteractionResponses): add message parameter (v13)

#8838 djs
This commit is contained in:
March 7th
2022-11-26 22:02:34 +07:00
parent b6d290d545
commit 69c5eb94d2
3 changed files with 37 additions and 25 deletions

View File

@@ -114,50 +114,57 @@ 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() {
if (this.ephemeral) throw new Error('INTERACTION_EPHEMERAL_REPLIED');
await this.webhook.deleteMessage('@original');
async deleteReply(message = '@original') {
await this.webhook.deleteMessage(message);
}
/**

View File

@@ -110,6 +110,7 @@ exports.HypeSquadType = createEnum(['LEAVE', 'HOUSE_BRAVERY', 'HOUSE_BRILLIANCE'
* * `TAIWAN_CHINESE`
* * `KOREAN`
* @typedef {Object<string, string>} localeSetting
* @see {@link https://discord.com/developers/docs/reference#locales}
*/
exports.localeSetting = {
da: 'DANISH',