diff --git a/index.d.ts b/index.d.ts index 438436773..18921b375 100644 --- a/index.d.ts +++ b/index.d.ts @@ -55,7 +55,9 @@ declare namespace Eris { type AdvancedMessageContent = { allowedMentions?: AllowedMentions; content?: string; + /** @deprecated */ embed?: EmbedOptions; + embeds?: EmbedOptions[]; flags?: number; messageReference?: MessageReferenceReply; /** @deprecated */ diff --git a/lib/Client.js b/lib/Client.js index ad3087cc8..bfd41d590 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -580,7 +580,8 @@ class Client extends EventEmitter { * @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 {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.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead + * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object} [content.messageReference] The message reference, used when replying to messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message @@ -601,8 +602,11 @@ class Client extends EventEmitter { }; } else if(content.content !== undefined && typeof content.content !== "string") { content.content = "" + content.content; - } else if(content.content === undefined && !content.embed && !file) { - return Promise.reject(new Error("No content, file, or embed")); + } else if(content.content === undefined && !content.embed && !content.embeds && !file) { + return Promise.reject(new Error("No content, file, or embeds")); + } else if(content.embed && !content.embeds) { + this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead"); + content.embeds = [content.embed]; } content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions); if(content.messageReference) { @@ -628,7 +632,7 @@ class Client extends EventEmitter { content.message_reference = {message_id: content.messageReferenceID}; } } else if(!file) { - return Promise.reject(new Error("No content, file, or embed")); + return Promise.reject(new Error("No content, file, or embeds")); } return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this)); } @@ -1222,7 +1226,8 @@ class Client extends EventEmitter { * @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.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead + * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference * @returns {Promise} */ @@ -1234,10 +1239,13 @@ class Client extends EventEmitter { }; } 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.embed && !content.embeds && content.flags === undefined) { + return Promise.reject(new Error("No content, embeds or flags")); + } else if(content.embed && !content.embeds) { + this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead"); + content.embeds = [content.embed]; } - if(content.content !== undefined || content.embed || content.allowedMentions) { + if(content.content !== undefined || content.embeds || content.allowedMentions) { content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions); } } diff --git a/lib/structures/PrivateChannel.js b/lib/structures/PrivateChannel.js index af77fe61b..1eff5c616 100644 --- a/lib/structures/PrivateChannel.js +++ b/lib/structures/PrivateChannel.js @@ -47,7 +47,8 @@ class PrivateChannel extends Channel { * @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} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to * @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.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead + * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object} [content.messageReference] The message reference, used when replying to messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message @@ -84,7 +85,8 @@ class PrivateChannel extends Channel { * @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 {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default) - * @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.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead + * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference * @returns {Promise} */ diff --git a/lib/structures/TextChannel.js b/lib/structures/TextChannel.js index 29f961d50..9ff0373bd 100644 --- a/lib/structures/TextChannel.js +++ b/lib/structures/TextChannel.js @@ -68,7 +68,8 @@ class TextChannel extends GuildChannel { * @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} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to * @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.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead + * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Object} [content.messageReference] The message reference, used when replying to messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message @@ -127,7 +128,8 @@ class TextChannel extends GuildChannel { * @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 {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default) - * @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.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead + * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference * @returns {Promise} */