Skip to content

Commit

Permalink
refactor: make requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Mar 12, 2022
1 parent 48fdac6 commit a3ebe36
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 32 deletions.
4 changes: 1 addition & 3 deletions packages/builders/src/components/Components.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { APIMessageComponent, APIModalComponent, ComponentType } from 'discord-api-types/v9';
import { ActionRowBuilder, ButtonBuilder, ComponentBuilder, SelectMenuBuilder, TextInputBuilder } from '../index';
import type { MessageComponentBuilder, ModalComponentBuilder } from './ActionRow';
import { UnknownComponentBuilder } from './UnknownComponent';

export interface MappedComponentTypes {
[ComponentType.ActionRow]: ActionRowBuilder;
Expand Down Expand Up @@ -37,7 +36,6 @@ export function createComponentBuilder(
default:
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
console.warn(`Cannot properly serialize component type: ${data.type}`);
return new UnknownComponentBuilder(data);
throw new Error(`Cannot properly serialize component type: ${data.type}`);
}
}
23 changes: 0 additions & 23 deletions packages/builders/src/components/UnknownComponent.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/discord.js/src/structures/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class Component {
*/
constructor(data) {
/**
* The API data associated with this button component
* The API data associated with this component
* @type {APIMessageComponent}
*/
this.data = { ...data };
this.data = data;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions packages/discord.js/src/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ class Components extends null {
case ComponentType.SelectMenu:
return new SelectMenuComponent(data);
default:
// This is done for future-proofing purposes to prevent
// crashes when unknown component types are found.
console.warn(`Found unknown component type: ${data.type}`);
return new Component(data);
throw new Error(`Found unknown component type: ${data.type}`);
}
}
}
Expand Down

0 comments on commit a3ebe36

Please sign in to comment.