mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
fix(Components): error with unknown components (#8724)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { ActionRowBuilder: BuildersActionRow, ComponentBuilder, isJSONEncodable } = require('@discordjs/builders');
|
const { ActionRowBuilder: BuildersActionRow, isJSONEncodable } = require('@discordjs/builders');
|
||||||
const { createComponentBuilder } = require('../util/Components');
|
const { createComponentBuilder } = require('../util/Components');
|
||||||
const { toSnakeCase } = require('../util/Transformers');
|
const { toSnakeCase } = require('../util/Transformers');
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ class ActionRowBuilder extends BuildersActionRow {
|
|||||||
constructor({ components, ...data } = {}) {
|
constructor({ components, ...data } = {}) {
|
||||||
super({
|
super({
|
||||||
...toSnakeCase(data),
|
...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:
|
case ComponentType.TextInput:
|
||||||
return new TextInputComponent(data);
|
return new TextInputComponent(data);
|
||||||
default:
|
default:
|
||||||
throw new Error(`Found unknown component type: ${data.type}`);
|
return new Component(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ function createComponentBuilder(data) {
|
|||||||
case ComponentType.TextInput:
|
case ComponentType.TextInput:
|
||||||
return new TextInputComponent(data);
|
return new TextInputComponent(data);
|
||||||
default:
|
default:
|
||||||
throw new Error(`Found unknown component type: ${data.type}`);
|
return new ComponentBuilder(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user