mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
types(ActionRow): allow components to be passed to constructors (#7531)
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const { ActionRow: BuildersActionRow } = require('@discordjs/builders');
|
||||
const { ActionRow: BuildersActionRow, Component } = require('@discordjs/builders');
|
||||
const Transformers = require('../util/Transformers');
|
||||
|
||||
class ActionRow extends BuildersActionRow {
|
||||
constructor(data) {
|
||||
super(Transformers.toSnakeCase(data));
|
||||
constructor({ components, ...data } = {}) {
|
||||
super({
|
||||
components: components?.map(c => (c instanceof Component ? c : Transformers.toSnakeCase(c))),
|
||||
...Transformers.toSnakeCase(data),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
packages/discord.js/typings/index.d.ts
vendored
8
packages/discord.js/typings/index.d.ts
vendored
@@ -209,10 +209,14 @@ export interface BaseComponentData {
|
||||
}
|
||||
|
||||
export type MessageActionRowComponentData = ButtonComponentData | SelectMenuComponentData;
|
||||
|
||||
export type ModalActionRowComponentData = TextInputComponentData;
|
||||
|
||||
export interface ActionRowData<T extends MessageActionRowComponentData | ModalActionRowComponentData>
|
||||
extends BaseComponentData {
|
||||
export type ActionRowComponentData = MessageActionRowComponentData | ModalActionRowComponentData;
|
||||
|
||||
export type ActionRowComponent = MessageActionRowComponent | ModalActionRowComponent;
|
||||
|
||||
export interface ActionRowData<T extends ActionRowComponent | ActionRowComponentData> extends BaseComponentData {
|
||||
components: T[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user