Skip to content

Commit

Permalink
fix(Components): error with unknown components (#8724)
Browse files Browse the repository at this point in the history
  • Loading branch information
1Computer1 committed Oct 8, 2022
1 parent 32297d4 commit 6fd331d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions 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');

Expand All @@ -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)),
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/util/Components.js
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down

0 comments on commit 6fd331d

Please sign in to comment.