mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
backport: fix circular conversion when editing RichEmbed
This commit is contained in:
@@ -7,6 +7,7 @@ const Collection = require('../../util/Collection');
|
||||
const Util = require('../../util/Util');
|
||||
const resolvePermissions = require('../../structures/shared/resolvePermissions');
|
||||
|
||||
const RichEmbed = require('../../structures/RichEmbed');
|
||||
const User = require('../../structures/User');
|
||||
const GuildMember = require('../../structures/GuildMember');
|
||||
const Message = require('../../structures/Message');
|
||||
@@ -140,6 +141,8 @@ class RESTMethods {
|
||||
content = `${mention}${content ? `, ${content}` : ''}`;
|
||||
}
|
||||
|
||||
if (embed instanceof RichEmbed) embed = embed._apiTransform();
|
||||
|
||||
return this.rest.makeRequest('patch', Endpoints.Message(message), true, {
|
||||
content, embed,
|
||||
}).then(data => this.client.actions.MessageUpdate.handle(data).updated);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Attachment = require('./Attachment');
|
||||
const MessageEmbed = require('./MessageEmbed');
|
||||
let ClientDataResolver;
|
||||
|
||||
/**
|
||||
@@ -247,19 +248,21 @@ class RichEmbed {
|
||||
url: this.url,
|
||||
timestamp: this.timestamp ? new Date(this.timestamp) : null,
|
||||
color: this.color,
|
||||
fields: this.fields,
|
||||
thumbnail: this.thumbnail,
|
||||
fields: this.fields ? this.fields.map(field => ({ name: field.name, value: field.value })) : null,
|
||||
thumbnail: this.thumbnail ? {
|
||||
url: this.thumbnail.url,
|
||||
} : null,
|
||||
image: this.image ? {
|
||||
url: this.image.url,
|
||||
} : null,
|
||||
author: this.author ? {
|
||||
name: this.author.name,
|
||||
url: this.author.url,
|
||||
icon_url: this.author.iconURL,
|
||||
icon_url: this.author instanceof MessageEmbed.Author ? this.author.iconURL : this.author.icon_url,
|
||||
} : null,
|
||||
footer: this.footer ? {
|
||||
text: this.footer.text,
|
||||
icon_url: this.footer.iconURL,
|
||||
icon_url: this.footer instanceof MessageEmbed.Footer ? this.footer.iconURL : this.footer.icon_url,
|
||||
} : null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user