diff --git a/src/structures/MessagePayload.js b/src/structures/MessagePayload.js index 339b8f9..b651c4b 100644 --- a/src/structures/MessagePayload.js +++ b/src/structures/MessagePayload.js @@ -3,6 +3,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'); const MessageFlags = require('../util/MessageFlags'); @@ -188,6 +189,21 @@ class MessagePayload { this.options.attachments = attachments; } + if (this.options.embeds) { + if (!Array.isArray(this.options.embeds)) { + this.options.embeds = [this.options.embeds]; + } + + let webembeds = this.options.embeds.filter(e => e instanceof WebEmbed); + this.options.embeds = this.options.embeds.filter(e => !(e instanceof WebEmbed)); + + while (webembeds.length) { + const embed = webembeds.shift(); + const data = await embed.toMessage(); + content +=`\n${data}` + } + } + this.data = { content, tts, diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 5d2daaa..04f748a 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 {MessageEmbed[]|APIEmbed[]} [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) diff --git a/typings/index.d.ts b/typings/index.d.ts index 01ac852..a32d98f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5247,7 +5247,7 @@ export interface MessageOptions { tts?: boolean; nonce?: string | number; content?: string | null; - embeds?: (MessageEmbed | MessageEmbedOptions | APIEmbed)[]; + embeds?: (WebEmbed | MessageEmbed | MessageEmbedOptions | APIEmbed)[]; components?: (MessageActionRow | (Required & MessageActionRowOptions))[]; allowedMentions?: MessageMentionOptions; files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];