Skip to content

Commit

Permalink
feat: component nested array support
Browse files Browse the repository at this point in the history
  • Loading branch information
monbrey committed Jun 9, 2021
1 parent 225fb71 commit 7cc5ae2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/structures/APIMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class APIMessage {
}
const embeds = embedLikes.map(e => new MessageEmbed(e).toJSON());

const components = this.options.components?.map(c => BaseMessageComponent.create(c).toJSON());
const components = this.options.components?.map(c =>
BaseMessageComponent.create(Array.isArray(c) ? { type: 1, components: c } : c).toJSON(),
);

let username;
let avatarURL;
Expand Down
4 changes: 2 additions & 2 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ class Message extends Base {
* @property {MessageAttachment[]} [attachments] An array of attachments to keep,
* all attachments will be kept if omitted
* @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] Files to add to the message
* @property {MessageActionRow[]} [components] Action rows containing interactive components for the message
* (buttons, select menus)
* @property {MessageActionRow[]|MessageActionRowOptions[]|MessageActionRowComponentResolvable[][]} [components]
* Action rows containing interactive components for the message (buttons, select menus)
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/structures/Webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class Webhook {
* @property {string} [content] See {@link BaseMessageOptions#content}
* @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] See {@link BaseMessageOptions#files}
* @property {MessageMentionOptions} [allowedMentions] See {@link BaseMessageOptions#allowedMentions}
* @property {MessageActionRow[]} [components] Action rows containing interactive components for the message
* (buttons, select menus)
* @property {MessageActionRow[]|MessageActionRowOptions[]|MessageActionRowComponentResolvable[][]} [components]
* Action rows containing interactive components for the message (buttons, select menus)
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/structures/interfaces/TextBasedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class TextBasedChannel {
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
* it exceeds the character limit. If an object is provided, these are the options for splitting the message
* @property {MessageActionRow[]} [components] Action rows containing interactive components for the message
* (buttons, select menus)
* @property {MessageActionRow[]|MessageActionRowOptions[]|MessageActionRowComponentResolvable[][]} [components]
* Action rows containing interactive components for the message (buttons, select menus)
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3454,7 +3454,7 @@ declare module 'discord.js' {
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
flags?: BitFieldResolvable<MessageFlagsString, number>;
allowedMentions?: MessageMentionOptions;
components?: MessageActionRow[] | MessageActionRowOptions[];
components?: MessageActionRow[] | MessageActionRowOptions[] | MessageActionRowComponentResolvable[][];
}

interface MessageEmbedAuthor {
Expand Down Expand Up @@ -3547,7 +3547,7 @@ declare module 'discord.js' {
nonce?: string | number;
content?: string;
embed?: MessageEmbed | MessageEmbedOptions;
components?: MessageActionRow[] | MessageActionRowOptions[];
components?: MessageActionRow[] | MessageActionRowOptions[] | MessageActionRowComponentResolvable[][];
allowedMentions?: MessageMentionOptions;
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
code?: string | boolean;
Expand Down

0 comments on commit 7cc5ae2

Please sign in to comment.