Update MessagePayload.js
This commit is contained in:
parent
4d96b4abe8
commit
e01bd304fc
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const { Buffer } = require('node:buffer');
|
const { Buffer } = require('node:buffer');
|
||||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||||
|
const MessageEmbed = require('./MessageEmbed');
|
||||||
const WebEmbed = require('./WebEmbed');
|
const WebEmbed = require('./WebEmbed');
|
||||||
const { RangeError } = require('../errors');
|
const { RangeError } = require('../errors');
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
@ -188,21 +189,21 @@ class MessagePayload {
|
|||||||
this.options.attachments = attachments;
|
this.options.attachments = attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.embeds) {
|
if (this.options.webembeds) {
|
||||||
//check if embeds is an array
|
//check if webembeds is an array
|
||||||
if (!Array.isArray(this.options.embeds)) {
|
if (!Array.isArray(this.options.embeds)) {
|
||||||
this.options.embeds = [this.options.embeds];
|
this.options.embeds = [this.options.embeds];
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if the embeds is an array of WebEmbed
|
//check if the webembeds is an array of WebEmbed
|
||||||
if (!this.options.embeds.every(e => e instanceof WebEmbed)) {
|
if (!this.options.webembeds.every(e => e instanceof WebEmbed)) {
|
||||||
throw new TypeError('WEB_EMBEDS_TYPE');
|
throw new TypeError('WEB_EMBEDS_TYPE');
|
||||||
}
|
}
|
||||||
|
|
||||||
//while loop to make sure all embeds will be added to the content
|
//while loop to make sure all embeds will be added to the content
|
||||||
while (this.options.embeds.length) {
|
while (this.options.webembeds.length) {
|
||||||
const embed = this.options.embeds.shift();
|
const webembeds = this.options.webembeds.shift();
|
||||||
const data = await embed.toMessage();
|
const data = await webembeds.toMessage();
|
||||||
content +=`\n${data}`
|
content +=`\n${data}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,6 +212,7 @@ class MessagePayload {
|
|||||||
content,
|
content,
|
||||||
tts,
|
tts,
|
||||||
nonce,
|
nonce,
|
||||||
|
embeds: this.options.embeds?.map(embed => new MessageEmbed(embed).toJSON()),
|
||||||
components,
|
components,
|
||||||
username,
|
username,
|
||||||
avatar_url: avatarURL,
|
avatar_url: avatarURL,
|
||||||
|
Loading…
Reference in New Issue
Block a user