From 27d2fa000cabe434fd81b45cb1d28b23aa68cac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Free=20=E5=85=AC=E5=9C=92?= <45021001+FreeAoi@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:31:54 -0600 Subject: [PATCH] Fix embed init data object reference (#274) * fix: avoid embed use initial object ref * chore: use spread operator instead --- src/builders/Embed.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/builders/Embed.ts b/src/builders/Embed.ts index ddcd0bd..f3430ad 100644 --- a/src/builders/Embed.ts +++ b/src/builders/Embed.ts @@ -11,14 +11,16 @@ import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter } from '.. * const embedJSON = embed.json(); */ export class Embed { + public data: Partial; /** * Creates a new instance of Embed. * @param data - The initial data for the embed. * @example * const embed = new Embed({ title: 'Hello', description: 'This is an example embed' }); */ - constructor(public data: Partial = {}) { - if (!data.fields) this.data.fields = []; + constructor(data: Partial = {}) { + this.data = { ...data }; + if (!this.data.fields) this.data.fields = []; } /**