From 4ade3751e71e11f4727e7af0c34984cc55514afe Mon Sep 17 00:00:00 2001 From: Canine8YT Date: Thu, 8 Jul 2021 11:27:33 -0500 Subject: [PATCH] Removed unneeded if statements, embed => embeds, fixed docs --- lib/structures/Interaction.js | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/structures/Interaction.js b/lib/structures/Interaction.js index 7a09e0a0f..bd8c9d0b7 100644 --- a/lib/structures/Interaction.js +++ b/lib/structures/Interaction.js @@ -67,8 +67,9 @@ class Interaction extends Base { } /** - * Note: You can **not** use more than 1 initial interaction response per interaction. * Acknowledges the interaction without replying. (Message Component only) + * Is a renamed deferUpdate() method + * Note: You can **not** use more than 1 initial interaction response per interaction. * @returns {Promise} */ async acknowledge() { @@ -85,7 +86,7 @@ class Interaction extends Base { * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. * @arg {String} content.content A content string - * @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @arg {Object} [content.embeds] An array of up to 10 embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Boolean} [content.flags] 64 for Ephemeral * @arg {Object | Array} [content.file] A file object (or an Array of them) * @arg {Buffer} content.file.file A buffer containing file data @@ -101,11 +102,6 @@ class Interaction extends Base { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.content === undefined && !content.embeds && content.flags === undefined) { - return Promise.reject(new Error("No content, embeds, or flags")); - } - if(content.content !== undefined || content.embed || content.allowedMentions) { - content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions); } } return this._client.executeWebhook.call(this._client, this.applicationId, this.token, content); @@ -120,7 +116,7 @@ class Interaction extends Base { * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. * @arg {String} content.content A content string - * @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @arg {Object} [content.embeds] An array of up to 10 embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Boolean} [content.flags] 64 for Ephemeral * @arg {Boolean} [content.tts] Set the message TTS flag * @returns {Promise} @@ -133,10 +129,10 @@ class Interaction extends Base { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.content === undefined && !content.embed && content.flags === undefined) { - return Promise.reject(new Error("No content, embed or flags")); + } else if(content.content === undefined && !content.embeds) { + return Promise.reject(new Error("No content or embeds")); } - if(content.content !== undefined || content.embed || content.allowedMentions) { + if(content.content !== undefined || content.embeds || content.allowedMentions) { content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions); } } @@ -191,7 +187,7 @@ class Interaction extends Base { * @arg {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. * @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. * @arg {String} [options.content=""] A content string - * @arg {Array} [options.embeds] An array of Discord embeds + * @arg {Object} [content.embeds] An array of up to 10 embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object | Array} [options.file] A file object (or an Array of them) * @arg {Buffer} options.file.file A buffer containing file data * @arg {String} options.file.name What to name the file @@ -205,15 +201,13 @@ class Interaction extends Base { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.content === undefined && !content.embeds && content.flags === undefined && content.flags === undefined) { - return Promise.reject(new Error("No content, embeds, components, or flags")); } } return this._client.editWebhookMessage.call(this._client, this.applicationId, this.token, messageId, content); } /** - * Edit the interaction Message + * Edit the interaction Message (Message Component only) * Note: You can **not** use more than 1 initial interaction response per interaction, use edit if you have already responded with a different interaction response. * @arg {String | Object} content What to edit the message with * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) @@ -222,7 +216,7 @@ class Interaction extends Base { * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. * @arg {String} [content.content=""] A content string - * @arg {Array} [content.embeds] An array of Discord embeds + * @arg {Object} [content.embeds] An array of up to 10 embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object | Array} [content.file] A file object (or an Array of them) * @arg {Buffer} content.file.file A buffer containing file data * @arg {String} content.file.name What to name the file @@ -236,10 +230,10 @@ class Interaction extends Base { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.content === undefined && !content.embed && content.components === undefined && content.flags === undefined) { - return Promise.reject(new Error("No content, embed, components, or flags")); + } else if(content.content === undefined && content.embeds === undefined && content.components === undefined) { + return Promise.reject(new Error("No content, embeds, or components")); } - if(content.content !== undefined || content.embed || content.allowedMentions) { + if(content.content !== undefined || content.embeds || content.allowedMentions) { content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions); } }