Skip to content

Commit

Permalink
docs: add docs for component data
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Feb 7, 2022
1 parent a1a968d commit 3178d2f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
45 changes: 44 additions & 1 deletion packages/discord.js/src/util/Components.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
'use strict';

/**
* @typedef {Object} BaseComponentData
* @property {ComponentType} type
*/

/**
* @typedef {BaseComponentData} ActionRowData
* @property {ComponentData[]} components
*/

/**
* @typedef {BaseComponentData} ButtonComponentData
* @property {ButtonStyle} style
* @property {?boolean} disabled
* @property {string} label
* @property {?APIComponentEmoji} emoji
* @property {?string} customId
* @property {?string} url
*/

/**
* @typedef {object} SelectMenuComponentOptionData
* @property {string} label
* @property {string} value
* @property {?string} description
* @property {?APIComponentEmoji} emoji
* @property {?boolean} default
*/

/**
* @typedef {BaseComponentData} SelectMenuComponentData
* @property {string} customId
* @property {?boolean} disabled
* @property {?number} maxValues
* @property {?number} minValues
* @property {?SelectMenuComponentOptionData[]} options
* @property {?string} placeholder
*/

/**
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData} ComponentData
*/

class Components extends null {
/**
* Transforms json data into api-compatible json data.
* @param {MessageComponentData|APIMessageComponent} data The data to transform.
* @param {ComponentData|APIMessageComponent} data The data to transform.
* @returns {APIMessageComponentData}
*/
static transformJSON(data) {
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4517,7 +4517,7 @@ export interface MessageActivity {

export interface BaseButtonComponentData extends BaseComponentData {
disabled?: boolean;
emoji?: EmojiIdentifierResolvable;
emoji?: APIMessageComponentEmoji;
label?: string;
}

Expand Down

0 comments on commit 3178d2f

Please sign in to comment.