Revert "Merge pull request #13 from lazuee/main"

This reverts commit fd7910de95, reversing
changes made to 44db21c06f.
This commit is contained in:
March 7th
2022-04-01 18:22:36 +07:00
parent fd7910de95
commit 5b0ebe175b
4 changed files with 18 additions and 63 deletions

View File

@@ -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,