From b4324f948769bcd6214d4ddf1a8ab4a4ba02dec7 Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Mon, 5 May 2025 20:01:16 -0400 Subject: [PATCH] fix: type error --- src/builders/Section.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/builders/Section.ts b/src/builders/Section.ts index 7c6bf85..d6f9e73 100644 --- a/src/builders/Section.ts +++ b/src/builders/Section.ts @@ -9,7 +9,7 @@ export class Section< Ac extends Button | Thumbnail = Button | Thumbnail, > extends BaseComponentBuilder { components: TextDisplay[]; - accessory!: Ac; + accessory?: Ac; constructor({ components, accessory, ...data }: Partial = {}) { super({ type: ComponentType.Section, ...data }); this.components = (components?.map(component => fromComponent(component)) ?? []) as TextDisplay[]; @@ -46,6 +46,7 @@ export class Section< * @returns The JSON representation of this section */ toJSON() { + if (!this.accessory) throw new Error('Cannot convert to JSON without an accessory.'); return { ...this.data, components: this.components.map(component => component.toJSON()),