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