mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
feat(MessageEmbed): change toJSON method to return an api-compatible object (#3813)
This commit is contained in:
@@ -152,7 +152,7 @@ class APIMessage {
|
|||||||
} else if (this.options.embed) {
|
} else if (this.options.embed) {
|
||||||
embedLikes.push(this.options.embed);
|
embedLikes.push(this.options.embed);
|
||||||
}
|
}
|
||||||
const embeds = embedLikes.map(e => new MessageEmbed(e)._apiTransform());
|
const embeds = embedLikes.map(e => new MessageEmbed(e).toJSON());
|
||||||
|
|
||||||
let username;
|
let username;
|
||||||
let avatarURL;
|
let avatarURL;
|
||||||
|
|||||||
@@ -317,16 +317,11 @@ class MessageEmbed {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
|
||||||
return Util.flatten(this, { hexColor: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the embed object to be processed.
|
* Transforms the embed to a plain object.
|
||||||
* @returns {Object} The raw data of this embed
|
* @returns {Object} The raw data of this embed
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
_apiTransform() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
title: this.title,
|
title: this.title,
|
||||||
type: 'rich',
|
type: 'rich',
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -1051,8 +1051,6 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
export class MessageEmbed {
|
export class MessageEmbed {
|
||||||
constructor(data?: MessageEmbed | MessageEmbedOptions);
|
constructor(data?: MessageEmbed | MessageEmbedOptions);
|
||||||
private _apiTransform(): MessageEmbedOptions;
|
|
||||||
|
|
||||||
public author: { name?: string; url?: string; iconURL?: string; proxyIconURL?: string } | null;
|
public author: { name?: string; url?: string; iconURL?: string; proxyIconURL?: string } | null;
|
||||||
public color: number;
|
public color: number;
|
||||||
public readonly createdAt: Date | null;
|
public readonly createdAt: Date | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user