revert: support for nested arrays of components, fix error handling (#6081)

This commit is contained in:
monbrey
2021-07-12 16:53:27 +10:00
committed by GitHub
parent dee5c83fc0
commit 1dcad051a8
8 changed files with 15 additions and 23 deletions

View File

@@ -53,11 +53,10 @@ class BaseMessageComponent {
* Constructs a MessageComponent based on the type of the incoming data
* @param {MessageComponentOptions} data Data for a MessageComponent
* @param {Client|WebhookClient} [client] Client constructing this component
* @param {boolean} [skipValidation=false] Whether or not to validate the component type
* @returns {?MessageComponent}
* @private
*/
static create(data, client, skipValidation = false) {
static create(data, client) {
let component;
let type = data.type;
@@ -66,7 +65,7 @@ class BaseMessageComponent {
switch (type) {
case MessageComponentTypes.ACTION_ROW: {
const MessageActionRow = require('./MessageActionRow');
component = new MessageActionRow(data);
component = new MessageActionRow(data, client);
break;
}
case MessageComponentTypes.BUTTON: {
@@ -82,7 +81,7 @@ class BaseMessageComponent {
default:
if (client) {
client.emit(Events.DEBUG, `[BaseMessageComponent] Received component with unknown type: ${data.type}`);
} else if (!skipValidation) {
} else {
throw new TypeError('INVALID_TYPE', 'data.type', 'valid MessageComponentType');
}
}