refactor(Interaction): rename defer to deferReply (#6306)

This commit is contained in:
Jan
2021-08-05 18:30:13 +02:00
committed by GitHub
parent 5b4efd13c9
commit 4241febe24
5 changed files with 26 additions and 16 deletions

View File

@@ -12,7 +12,7 @@ const MessagePayload = require('../MessagePayload');
class InteractionResponses {
/**
* Options for deferring the reply to an {@link Interaction}.
* @typedef {Object} InteractionDeferOptions
* @typedef {Object} InteractionDeferReplyOptions
* @property {boolean} [ephemeral] Whether the reply should be ephemeral
* @property {boolean} [fetchReply] Whether to fetch the reply
*/
@@ -38,20 +38,20 @@ class InteractionResponses {
/**
* Defers the reply to this interaction.
* @param {InteractionDeferOptions} [options] Options for deferring the reply to this interaction
* @param {InteractionDeferReplyOptions} [options] Options for deferring the reply to this interaction
* @returns {Promise<Message|APIMessage|void>}
* @example
* // Defer the reply to this interaction
* interaction.defer()
* interaction.deferReply()
* .then(console.log)
* .catch(console.error)
* @example
* // Defer to send an ephemeral reply later
* interaction.defer({ ephemeral: true })
* interaction.deferReply({ ephemeral: true })
* .then(console.log)
* .catch(console.error);
*/
async defer(options = {}) {
async deferReply(options = {}) {
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
if (options.fetchReply && options.ephemeral) throw new Error('INTERACTION_FETCH_EPHEMERAL');
this.ephemeral = options.ephemeral ?? false;
@@ -228,7 +228,17 @@ class InteractionResponses {
}
static applyToClass(structure, ignore = []) {
const props = ['defer', 'reply', 'fetchReply', 'editReply', 'deleteReply', 'followUp', 'deferUpdate', 'update'];
const props = [
'deferReply',
'reply',
'fetchReply',
'editReply',
'deleteReply',
'followUp',
'deferUpdate',
'update',
];
for (const prop of props) {
if (ignore.includes(prop)) continue;
Object.defineProperty(