mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
fix(ActionRow): toJSON should include components (#7739)
* fix(ActionRow): toJSON should include components * Update packages/discord.js/src/structures/ActionRow.js Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> * types: extend component Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Co-authored-by: suneettipirneni <suneettipirneni@icloud.com>
This commit is contained in:
@@ -17,6 +17,14 @@ class ActionRow extends Component {
|
|||||||
*/
|
*/
|
||||||
this.components = components.map(c => Components.createComponent(c));
|
this.components = components.map(c => Components.createComponent(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the API-compatible JSON for this component
|
||||||
|
* @returns {APIActionRowComponent}
|
||||||
|
*/
|
||||||
|
toJSON() {
|
||||||
|
return { ...this.data, components: this.components.map(c => c.toJSON()) };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ActionRow;
|
module.exports = ActionRow;
|
||||||
|
|||||||
14
packages/discord.js/typings/index.d.ts
vendored
14
packages/discord.js/typings/index.d.ts
vendored
@@ -246,9 +246,12 @@ export class ActionRowBuilder<
|
|||||||
export type MessageActionRowComponent = ButtonComponent | SelectMenuComponent;
|
export type MessageActionRowComponent = ButtonComponent | SelectMenuComponent;
|
||||||
export type ModalActionRowComponent = TextInputComponent;
|
export type ModalActionRowComponent = TextInputComponent;
|
||||||
|
|
||||||
export class ActionRow<T extends MessageActionRowComponent | ModalActionRowComponent> {
|
export class ActionRow<T extends MessageActionRowComponent | ModalActionRowComponent> extends Component<
|
||||||
private constructor(data: APIActionRowComponent<APIMessageActionRowComponent>);
|
APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
|
||||||
|
> {
|
||||||
|
private constructor(data: APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>);
|
||||||
public readonly components: T[];
|
public readonly components: T[];
|
||||||
|
public toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ActivityFlagsBitField extends BitField<ActivityFlagsString> {
|
export class ActivityFlagsBitField extends BitField<ActivityFlagsString> {
|
||||||
@@ -527,7 +530,12 @@ export class ButtonInteraction<Cached extends CacheType = CacheType> extends Mes
|
|||||||
public inRawGuild(): this is ButtonInteraction<'raw'>;
|
public inRawGuild(): this is ButtonInteraction<'raw'>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Component<T extends APIMessageComponent | APIModalComponent = APIMessageComponent | APIModalComponent> {
|
export type AnyComponent =
|
||||||
|
| APIMessageComponent
|
||||||
|
| APIModalComponent
|
||||||
|
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>;
|
||||||
|
|
||||||
|
export class Component<T extends AnyComponent = AnyComponent> {
|
||||||
public readonly data: Readonly<T>;
|
public readonly data: Readonly<T>;
|
||||||
public get type(): T['type'];
|
public get type(): T['type'];
|
||||||
public toJSON(): T;
|
public toJSON(): T;
|
||||||
|
|||||||
Reference in New Issue
Block a user