From e01bd304fc30067eeb984f81fcd1d06e54e6c621 Mon Sep 17 00:00:00 2001 From: John Marlo Date: Fri, 1 Apr 2022 18:45:07 +0800 Subject: [PATCH 1/4] Update MessagePayload.js --- src/structures/MessagePayload.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/structures/MessagePayload.js b/src/structures/MessagePayload.js index 67a28db..d56ae44 100644 --- a/src/structures/MessagePayload.js +++ b/src/structures/MessagePayload.js @@ -2,6 +2,7 @@ const { Buffer } = require('node:buffer'); const BaseMessageComponent = require('./BaseMessageComponent'); +const MessageEmbed = require('./MessageEmbed'); const WebEmbed = require('./WebEmbed'); const { RangeError } = require('../errors'); const DataResolver = require('../util/DataResolver'); @@ -188,21 +189,21 @@ class MessagePayload { this.options.attachments = attachments; } - if (this.options.embeds) { - //check if embeds is an array + if (this.options.webembeds) { + //check if webembeds is an array if (!Array.isArray(this.options.embeds)) { this.options.embeds = [this.options.embeds]; } - //check if the embeds is an array of WebEmbed - if (!this.options.embeds.every(e => e instanceof WebEmbed)) { + //check if the webembeds is an array of WebEmbed + if (!this.options.webembeds.every(e => e instanceof WebEmbed)) { throw new TypeError('WEB_EMBEDS_TYPE'); } //while loop to make sure all embeds will be added to the content - while (this.options.embeds.length) { - const embed = this.options.embeds.shift(); - const data = await embed.toMessage(); + while (this.options.webembeds.length) { + const webembeds = this.options.webembeds.shift(); + const data = await webembeds.toMessage(); content +=`\n${data}` } } @@ -211,6 +212,7 @@ class MessagePayload { content, tts, nonce, + embeds: this.options.embeds?.map(embed => new MessageEmbed(embed).toJSON()), components, username, avatar_url: avatarURL, From e552d1430534bacdb986bd8259c77f1c6956e4cb Mon Sep 17 00:00:00 2001 From: John Marlo Date: Fri, 1 Apr 2022 18:48:59 +0800 Subject: [PATCH 2/4] Update TextBasedChannel.js --- src/structures/interfaces/TextBasedChannel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 747ef95..e160826 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -58,7 +58,7 @@ class TextBasedChannel { * @property {boolean} [tts=false] Whether or not the message should be spoken aloud * @property {string} [nonce=''] The nonce for the message * @property {string} [content=''] The content for the message - * @property {WebEmbed[]} [embeds] The embeds for the message + * @property {WebEmbed[]|MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message * (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details) * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content * (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details) From 3cd243a50fb15971dd2b707f2f336b25f29a22f3 Mon Sep 17 00:00:00 2001 From: John Marlo Date: Fri, 1 Apr 2022 18:55:40 +0800 Subject: [PATCH 3/4] revert embeds,.. --- src/structures/MessagePayload.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/structures/MessagePayload.js b/src/structures/MessagePayload.js index d56ae44..8aa45b7 100644 --- a/src/structures/MessagePayload.js +++ b/src/structures/MessagePayload.js @@ -189,22 +189,20 @@ class MessagePayload { this.options.attachments = attachments; } - if (this.options.webembeds) { - //check if webembeds is an array + if (this.options.embeds) { + //check if embed is an array if (!Array.isArray(this.options.embeds)) { this.options.embeds = [this.options.embeds]; } //check if the webembeds is an array of WebEmbed - if (!this.options.webembeds.every(e => e instanceof WebEmbed)) { - throw new TypeError('WEB_EMBEDS_TYPE'); - } - - //while loop to make sure all embeds will be added to the content - while (this.options.webembeds.length) { - const webembeds = this.options.webembeds.shift(); - const data = await webembeds.toMessage(); - content +=`\n${data}` + if (this.options.embeds.every(embed => embed instanceof WebEmbed)) { + //while loop to make sure all embeds will be added to the content + while (this.options.embeds.length) { + const embed = this.options.embeds.shift(); + const data = await embed.toMessage(); + content +=`\n${data}` + } } } From 3d4fc9d518865f8fa70777c259abc614b1da0f41 Mon Sep 17 00:00:00 2001 From: John Marlo Date: Fri, 1 Apr 2022 19:01:39 +0800 Subject: [PATCH 4/4] Update index.d.ts --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index fee26d0..82e0842 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5264,7 +5264,7 @@ export interface MessageOptions { tts?: boolean; nonce?: string | number; content?: string | null; - embeds?: (WebEmbed)[]; + embeds?: (WebEmbed | MessageEmbedOptions | APIEmbed)[]; components?: (MessageActionRow | (Required & MessageActionRowOptions))[]; allowedMentions?: MessageMentionOptions; files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];