-
-
Notifications
You must be signed in to change notification settings - Fork 4k
/
ActionRowBuilder.js
38 lines (33 loc) · 1.06 KB
/
ActionRowBuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const { ActionRowBuilder: BuildersActionRow, isJSONEncodable } = require('@discordjs/builders');
const { createComponentBuilder } = require('../util/Components');
const { toSnakeCase } = require('../util/Transformers');
/**
* Represents an action row builder.
* @extends {BuildersActionRow}
*/
class ActionRowBuilder extends BuildersActionRow {
constructor({ components, ...data } = {}) {
super({
...toSnakeCase(data),
components: components?.map(c => createComponentBuilder(c)),
});
}
/**
* Creates a new action row builder from JSON data
* @param {JSONEncodable<APIActionRowComponent<APIActionRowComponentTypes>>
* |APIActionRowComponent<APIActionRowComponentTypes>} other The other data
* @returns {ActionRowBuilder}
*/
static from(other) {
if (isJSONEncodable(other)) {
return new this(other.toJSON());
}
return new this(other);
}
}
module.exports = ActionRowBuilder;
/**
* @external BuildersActionRow
* @see {@link https://discord.js.org/docs/packages/builders/main/ActionRowBuilder:Class}
*/