Revert "Merge pull request #13 from lazuee/main"
This reverts commitfd7910de95, reversing changes made to44db21c06f.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
const { Buffer } = require('node:buffer');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const WebEmbed = require('./WebEmbed');
|
||||
const MessageEmbed = require('./MessageEmbed');
|
||||
const { RangeError } = require('../errors');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const MessageFlags = require('../util/MessageFlags');
|
||||
@@ -121,12 +121,12 @@ class MessagePayload {
|
||||
* Resolves data.
|
||||
* @returns {MessagePayload}
|
||||
*/
|
||||
async resolveData() {
|
||||
resolveData() {
|
||||
if (this.data) return this;
|
||||
const isInteraction = this.isInteraction;
|
||||
const isWebhook = this.isWebhook;
|
||||
|
||||
let content = this.makeContent();
|
||||
const content = this.makeContent();
|
||||
const tts = Boolean(this.options.tts);
|
||||
|
||||
let nonce;
|
||||
@@ -188,29 +188,11 @@ class MessagePayload {
|
||||
this.options.attachments = attachments;
|
||||
}
|
||||
|
||||
if (this.options.embeds) {
|
||||
//check if embeds 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)) {
|
||||
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();
|
||||
content +=`\n${data}`
|
||||
}
|
||||
}
|
||||
|
||||
this.data = {
|
||||
content,
|
||||
tts,
|
||||
nonce,
|
||||
embeds: this.options.embeds?.map(embed => new MessageEmbed(embed).toJSON()),
|
||||
components,
|
||||
username,
|
||||
avatar_url: avatarURL,
|
||||
|
||||
Reference in New Issue
Block a user