mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(Components): error with unknown components (#8724)
This commit is contained in:
@@ -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)),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user