From 68567a27c48101c1761637db3a542761f47d9f08 Mon Sep 17 00:00:00 2001 From: 1Computer1 <22125769+1Computer1@users.noreply.github.com> Date: Sat, 8 Oct 2022 01:59:42 -0400 Subject: [PATCH] fix(Components): error with unknown components --- packages/discord.js/src/structures/ActionRowBuilder.js | 4 ++-- packages/discord.js/src/util/Components.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/structures/ActionRowBuilder.js b/packages/discord.js/src/structures/ActionRowBuilder.js index 379b0e1f4327..eb5f27630a61 100644 --- a/packages/discord.js/src/structures/ActionRowBuilder.js +++ b/packages/discord.js/src/structures/ActionRowBuilder.js @@ -1,6 +1,6 @@ 'use strict'; -const { ActionRowBuilder: BuildersActionRow, ComponentBuilder, isJSONEncodable } = require('@discordjs/builders'); +const { ActionRowBuilder: BuildersActionRow, isJSONEncodable } = require('@discordjs/builders'); const { createComponentBuilder } = require('../util/Components'); const { toSnakeCase } = require('../util/Transformers'); @@ -12,7 +12,7 @@ class ActionRowBuilder extends BuildersActionRow { constructor({ components, ...data } = {}) { super({ ...toSnakeCase(data), - components: components?.map(c => (c instanceof ComponentBuilder ? c : createComponentBuilder(c))), + components: components?.map(c => createComponentBuilder(c)), }); } diff --git a/packages/discord.js/src/util/Components.js b/packages/discord.js/src/util/Components.js index ca3f02ccae24..07032c089cb3 100644 --- a/packages/discord.js/src/util/Components.js +++ b/packages/discord.js/src/util/Components.js @@ -87,7 +87,7 @@ function createComponent(data) { case ComponentType.TextInput: return new TextInputComponent(data); default: - throw new Error(`Found unknown component type: ${data.type}`); + return new Component(data); } } @@ -111,7 +111,7 @@ function createComponentBuilder(data) { case ComponentType.TextInput: return new TextInputComponent(data); default: - throw new Error(`Found unknown component type: ${data.type}`); + return new ComponentBuilder(data); } }