From 4abb28c0a1256c57a60369a6b8ec9e98c265b489 Mon Sep 17 00:00:00 2001 From: D Trombett Date: Wed, 2 Feb 2022 21:43:27 +0100 Subject: [PATCH] fix(builders): make type optional in constructor (#7391) --- packages/builders/src/components/ActionRow.ts | 2 +- packages/builders/src/components/Button.ts | 2 +- packages/builders/src/components/selectMenu/SelectMenu.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/builders/src/components/ActionRow.ts b/packages/builders/src/components/ActionRow.ts index 3da6b625f8df..a8a175b4c8f4 100644 --- a/packages/builders/src/components/ActionRow.ts +++ b/packages/builders/src/components/ActionRow.ts @@ -16,7 +16,7 @@ export class ActionRow implem public readonly components: T[] = []; public readonly type = ComponentType.ActionRow; - public constructor(data?: APIActionRowComponent) { + public constructor(data?: APIActionRowComponent & { type?: ComponentType.ActionRow }) { this.components = (data?.components.map(createComponent) ?? []) as T[]; } diff --git a/packages/builders/src/components/Button.ts b/packages/builders/src/components/Button.ts index 3b7835dcd187..c394f3b1d15e 100644 --- a/packages/builders/src/components/Button.ts +++ b/packages/builders/src/components/Button.ts @@ -19,7 +19,7 @@ export class ButtonComponent implements Component { public readonly custom_id!: string; public readonly url!: string; - public constructor(data?: APIButtonComponent) { + public constructor(data?: APIButtonComponent & { type?: ComponentType.Button }) { /* eslint-disable @typescript-eslint/non-nullable-type-assertion-style */ this.style = data?.style as ButtonStyle; this.label = data?.label; diff --git a/packages/builders/src/components/selectMenu/SelectMenu.ts b/packages/builders/src/components/selectMenu/SelectMenu.ts index b85c420416f8..51c87d537b05 100644 --- a/packages/builders/src/components/selectMenu/SelectMenu.ts +++ b/packages/builders/src/components/selectMenu/SelectMenu.ts @@ -21,7 +21,7 @@ export class SelectMenuComponent implements Component { public readonly custom_id!: string; public readonly disabled?: boolean; - public constructor(data?: APISelectMenuComponent) { + public constructor(data?: APISelectMenuComponent & { type?: ComponentType.SelectMenu }) { this.options = data?.options.map((option) => new SelectMenuOption(option)) ?? []; this.placeholder = data?.placeholder; this.min_values = data?.min_values;