Fix embed init data object reference (#274)

* fix: avoid embed use initial object ref

* chore: use spread operator instead
This commit is contained in:
Free 公園 2024-10-07 22:31:54 -06:00 committed by GitHub
parent 2912296d96
commit 27d2fa000c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,14 +11,16 @@ import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter } from '..
* const embedJSON = embed.json(); * const embedJSON = embed.json();
*/ */
export class Embed { export class Embed {
public data: Partial<APIEmbed>;
/** /**
* Creates a new instance of Embed. * Creates a new instance of Embed.
* @param data - The initial data for the embed. * @param data - The initial data for the embed.
* @example * @example
* const embed = new Embed({ title: 'Hello', description: 'This is an example embed' }); * const embed = new Embed({ title: 'Hello', description: 'This is an example embed' });
*/ */
constructor(public data: Partial<APIEmbed> = {}) { constructor(data: Partial<APIEmbed> = {}) {
if (!data.fields) this.data.fields = []; this.data = { ...data };
if (!this.data.fields) this.data.fields = [];
} }
/** /**