Skip to content

Commit

Permalink
Removed unneeded if statements, embed => embeds, fixed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JustCat80 committed Jul 8, 2021
1 parent e8221b8 commit 4ade375
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions lib/structures/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -85,7 +86,7 @@ class Interaction extends Base {
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
* @arg {Boolean | Array<String>} [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<Object>} [content.file] A file object (or an Array of them)
* @arg {Buffer} content.file.file A buffer containing file data
Expand All @@ -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);
Expand All @@ -120,7 +116,7 @@ class Interaction extends Base {
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
* @arg {Boolean | Array<String>} [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}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -191,7 +187,7 @@ class Interaction extends Base {
* @arg {Boolean | Array<String>} [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<Object>} [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<Object>} [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
Expand All @@ -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)
Expand All @@ -222,7 +216,7 @@ class Interaction extends Base {
* @arg {Boolean | Array<String>} [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<Object>} [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<Object>} [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
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 4ade375

Please sign in to comment.