mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03: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';
|
'use strict';
|
||||||
|
|
||||||
const { ActionRow: BuildersActionRow } = require('@discordjs/builders');
|
const { ActionRow: BuildersActionRow, Component } = require('@discordjs/builders');
|
||||||
const Transformers = require('../util/Transformers');
|
const Transformers = require('../util/Transformers');
|
||||||
|
|
||||||
class ActionRow extends BuildersActionRow {
|
class ActionRow extends BuildersActionRow {
|
||||||
constructor(data) {
|
constructor({ components, ...data } = {}) {
|
||||||
super(Transformers.toSnakeCase(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 MessageActionRowComponentData = ButtonComponentData | SelectMenuComponentData;
|
||||||
|
|
||||||
export type ModalActionRowComponentData = TextInputComponentData;
|
export type ModalActionRowComponentData = TextInputComponentData;
|
||||||
|
|
||||||
export interface ActionRowData<T extends MessageActionRowComponentData | ModalActionRowComponentData>
|
export type ActionRowComponentData = MessageActionRowComponentData | ModalActionRowComponentData;
|
||||||
extends BaseComponentData {
|
|
||||||
|
export type ActionRowComponent = MessageActionRowComponent | ModalActionRowComponent;
|
||||||
|
|
||||||
|
export interface ActionRowData<T extends ActionRowComponent | ActionRowComponentData> extends BaseComponentData {
|
||||||
components: T[];
|
components: T[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user