mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
backport: fix circular conversion in RichEmbed
This commit is contained in:
@@ -39,7 +39,7 @@ class RichEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Timestamp for this Embed
|
* Timestamp for this Embed
|
||||||
* @type {Date}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.timestamp = data.timestamp;
|
this.timestamp = data.timestamp;
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ class RichEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the timestamp of this embed.
|
* Sets the timestamp of this embed.
|
||||||
* @param {Date} [timestamp=current date] The timestamp
|
* @param {Date} [timestamp=new Date()] The timestamp
|
||||||
* @returns {RichEmbed} This embed
|
* @returns {RichEmbed} This embed
|
||||||
*/
|
*/
|
||||||
setTimestamp(timestamp = new Date()) {
|
setTimestamp(timestamp = new Date()) {
|
||||||
@@ -215,6 +215,36 @@ class RichEmbed {
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms the embed object to be processed.
|
||||||
|
* @returns {Object} The raw data of this embed
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_apiTransform() {
|
||||||
|
return {
|
||||||
|
title: this.title,
|
||||||
|
type: 'rich',
|
||||||
|
description: this.description,
|
||||||
|
url: this.url,
|
||||||
|
timestamp: this.timestamp ? new Date(this.timestamp) : null,
|
||||||
|
color: this.color,
|
||||||
|
fields: this.fields,
|
||||||
|
thumbnail: this.thumbnail,
|
||||||
|
image: this.image ? {
|
||||||
|
url: this.image.url,
|
||||||
|
} : null,
|
||||||
|
author: this.author ? {
|
||||||
|
name: this.author.name,
|
||||||
|
url: this.author.url,
|
||||||
|
icon_url: this.author.iconURL,
|
||||||
|
} : null,
|
||||||
|
footer: this.footer ? {
|
||||||
|
text: this.footer.text,
|
||||||
|
icon_url: this.footer.iconURL,
|
||||||
|
} : null,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RichEmbed;
|
module.exports = RichEmbed;
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ class Webhook {
|
|||||||
else options.files = files;
|
else options.files = files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.embeds) options.embeds = options.embeds.map(e => new RichEmbed(e)._apiTransform());
|
||||||
|
|
||||||
if (options.files) {
|
if (options.files) {
|
||||||
for (let i = 0; i < options.files.length; i++) {
|
for (let i = 0; i < options.files.length; i++) {
|
||||||
let file = options.files[i];
|
let file = options.files[i];
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ class TextBasedChannel {
|
|||||||
else options.files = [options.file];
|
else options.files = [options.file];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.embed) options.embed = new RichEmbed(options.embed)._apiTransform();
|
||||||
|
|
||||||
if (options.files) {
|
if (options.files) {
|
||||||
for (let i = 0; i < options.files.length; i++) {
|
for (let i = 0; i < options.files.length; i++) {
|
||||||
let file = options.files[i];
|
let file = options.files[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user