Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(builders): make type optional in constructor #7391

Merged
merged 1 commit into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/builders/src/components/ActionRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> 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[];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down