discord.js 15.0.0-dev.1745947844-82435c308 → 15.0.0-dev.1746144802-75179fbf9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/index.js +0 -9
- package/src/structures/Component.js +0 -9
- package/src/structures/Message.js +4 -4
- package/src/structures/MessageComponentInteraction.js +4 -3
- package/src/structures/MessagePayload.js +1 -2
- package/src/structures/interfaces/TextBasedChannel.js +3 -8
- package/src/util/APITypes.js +2 -42
- package/src/util/Components.js +18 -130
- package/typings/index.d.mts +9 -176
- package/typings/index.d.ts +9 -176
- package/typings/index.test-d.ts +3 -66
- package/src/structures/ContainerComponent.js +0 -60
- package/src/structures/FileComponent.js +0 -40
- package/src/structures/MediaGalleryComponent.js +0 -31
- package/src/structures/MediaGalleryItem.js +0 -51
- package/src/structures/SectionComponent.js +0 -42
- package/src/structures/SeparatorComponent.js +0 -30
- package/src/structures/TextDisplayComponent.js +0 -20
- package/src/structures/ThumbnailComponent.js +0 -49
- package/src/structures/UnfurledMediaItem.js +0 -25
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "discord.js",
|
|
4
|
-
"version": "15.0.0-dev.
|
|
4
|
+
"version": "15.0.0-dev.1746144802-75179fbf9",
|
|
5
5
|
"description": "A powerful library for interacting with the Discord API",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./typings/index.d.ts",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@discordjs/collection": "^2.1.1",
|
|
65
65
|
"@discordjs/formatters": "^0.6.1",
|
|
66
66
|
"@discordjs/util": "^1.1.1",
|
|
67
|
-
"@discordjs/
|
|
68
|
-
"@discordjs/
|
|
67
|
+
"@discordjs/rest": "^2.5.0",
|
|
68
|
+
"@discordjs/ws": "^2.0.2"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@favware/cliff-jumper": "^4.1.0",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"tslint": "6.1.3",
|
|
86
86
|
"turbo": "^2.5.2",
|
|
87
87
|
"typescript": "~5.8.3",
|
|
88
|
-
"@discordjs/api-extractor": "^7.38.1",
|
|
89
88
|
"@discordjs/docgen": "^0.12.1",
|
|
89
|
+
"@discordjs/api-extractor": "^7.38.1",
|
|
90
90
|
"@discordjs/scripts": "^0.1.0"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
package/src/index.js
CHANGED
|
@@ -131,14 +131,12 @@ exports.CommandInteraction = require('./structures/CommandInteraction.js').Comma
|
|
|
131
131
|
exports.CommandInteractionOptionResolver =
|
|
132
132
|
require('./structures/CommandInteractionOptionResolver.js').CommandInteractionOptionResolver;
|
|
133
133
|
exports.Component = require('./structures/Component.js').Component;
|
|
134
|
-
exports.ContainerComponent = require('./structures/ContainerComponent.js').ContainerComponent;
|
|
135
134
|
exports.ContextMenuCommandInteraction =
|
|
136
135
|
require('./structures/ContextMenuCommandInteraction.js').ContextMenuCommandInteraction;
|
|
137
136
|
exports.DMChannel = require('./structures/DMChannel.js').DMChannel;
|
|
138
137
|
exports.Embed = require('./structures/Embed.js').Embed;
|
|
139
138
|
exports.Emoji = require('./structures/Emoji.js').Emoji;
|
|
140
139
|
exports.Entitlement = require('./structures/Entitlement.js').Entitlement;
|
|
141
|
-
exports.FileComponent = require('./structures/FileComponent.js').FileComponent;
|
|
142
140
|
exports.ForumChannel = require('./structures/ForumChannel.js').ForumChannel;
|
|
143
141
|
exports.Guild = require('./structures/Guild.js').Guild;
|
|
144
142
|
exports.GuildAuditLogs = require('./structures/GuildAuditLogs.js').GuildAuditLogs;
|
|
@@ -167,8 +165,6 @@ exports.InteractionWebhook = require('./structures/InteractionWebhook.js').Inter
|
|
|
167
165
|
exports.Invite = require('./structures/Invite.js').Invite;
|
|
168
166
|
exports.InviteGuild = require('./structures/InviteGuild.js').InviteGuild;
|
|
169
167
|
exports.MediaChannel = require('./structures/MediaChannel.js').MediaChannel;
|
|
170
|
-
exports.MediaGalleryComponent = require('./structures/MediaGalleryComponent.js').MediaGalleryComponent;
|
|
171
|
-
exports.MediaGalleryItem = require('./structures/MediaGalleryItem.js').MediaGalleryItem;
|
|
172
168
|
exports.MentionableSelectMenuComponent =
|
|
173
169
|
require('./structures/MentionableSelectMenuComponent.js').MentionableSelectMenuComponent;
|
|
174
170
|
exports.MentionableSelectMenuInteraction =
|
|
@@ -200,8 +196,6 @@ exports.RichPresenceAssets = require('./structures/Presence.js').RichPresenceAss
|
|
|
200
196
|
exports.Role = require('./structures/Role.js').Role;
|
|
201
197
|
exports.RoleSelectMenuComponent = require('./structures/RoleSelectMenuComponent.js').RoleSelectMenuComponent;
|
|
202
198
|
exports.RoleSelectMenuInteraction = require('./structures/RoleSelectMenuInteraction.js').RoleSelectMenuInteraction;
|
|
203
|
-
exports.SectionComponent = require('./structures/SectionComponent.js').SectionComponent;
|
|
204
|
-
exports.SeparatorComponent = require('./structures/SeparatorComponent.js').SeparatorComponent;
|
|
205
199
|
exports.SKU = require('./structures/SKU.js').SKU;
|
|
206
200
|
exports.SoundboardSound = require('./structures/SoundboardSound.js').SoundboardSound;
|
|
207
201
|
exports.StageChannel = require('./structures/StageChannel.js').StageChannel;
|
|
@@ -215,14 +209,11 @@ exports.Subscription = require('./structures/Subscription.js').Subscription;
|
|
|
215
209
|
exports.Team = require('./structures/Team.js').Team;
|
|
216
210
|
exports.TeamMember = require('./structures/TeamMember.js').TeamMember;
|
|
217
211
|
exports.TextChannel = require('./structures/TextChannel.js').TextChannel;
|
|
218
|
-
exports.TextDisplayComponent = require('./structures/TextDisplayComponent.js').TextDisplayComponent;
|
|
219
212
|
exports.TextInputComponent = require('./structures/TextInputComponent.js').TextInputComponent;
|
|
220
213
|
exports.ThreadChannel = require('./structures/ThreadChannel.js').ThreadChannel;
|
|
221
214
|
exports.ThreadMember = require('./structures/ThreadMember.js').ThreadMember;
|
|
222
215
|
exports.ThreadOnlyChannel = require('./structures/ThreadOnlyChannel.js').ThreadOnlyChannel;
|
|
223
|
-
exports.ThumbnailComponent = require('./structures/ThumbnailComponent.js').ThumbnailComponent;
|
|
224
216
|
exports.Typing = require('./structures/Typing.js').Typing;
|
|
225
|
-
exports.UnfurledMediaItem = require('./structures/UnfurledMediaItem.js').UnfurledMediaItem;
|
|
226
217
|
exports.User = require('./structures/User.js').User;
|
|
227
218
|
exports.UserContextMenuCommandInteraction =
|
|
228
219
|
require('./structures/UserContextMenuCommandInteraction.js').UserContextMenuCommandInteraction;
|
|
@@ -23,7 +23,7 @@ const { ReactionCollector } = require('./ReactionCollector.js');
|
|
|
23
23
|
const { Sticker } = require('./Sticker.js');
|
|
24
24
|
const { DiscordjsError, ErrorCodes } = require('../errors/index.js');
|
|
25
25
|
const { ReactionManager } = require('../managers/ReactionManager.js');
|
|
26
|
-
const { createComponent
|
|
26
|
+
const { createComponent } = require('../util/Components.js');
|
|
27
27
|
const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require('../util/Constants.js');
|
|
28
28
|
const { MessageFlagsBitField } = require('../util/MessageFlagsBitField.js');
|
|
29
29
|
const { PermissionsBitField } = require('../util/PermissionsBitField.js');
|
|
@@ -151,10 +151,10 @@ class Message extends Base {
|
|
|
151
151
|
|
|
152
152
|
if ('components' in data) {
|
|
153
153
|
/**
|
|
154
|
-
* An array of
|
|
154
|
+
* An array of action rows in the message.
|
|
155
155
|
* <info>This property requires the {@link GatewayIntentBits.MessageContent} privileged intent
|
|
156
156
|
* in a guild for messages that do not mention the client.</info>
|
|
157
|
-
* @type {
|
|
157
|
+
* @type {ActionRow[]}
|
|
158
158
|
*/
|
|
159
159
|
this.components = data.components.map(component => createComponent(component));
|
|
160
160
|
} else {
|
|
@@ -1032,7 +1032,7 @@ class Message extends Base {
|
|
|
1032
1032
|
* @returns {?MessageActionRowComponent}
|
|
1033
1033
|
*/
|
|
1034
1034
|
resolveComponent(customId) {
|
|
1035
|
-
return
|
|
1035
|
+
return this.components.flatMap(row => row.components).find(component => component.customId === customId) ?? null;
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
1038
1038
|
/**
|
|
@@ -4,7 +4,6 @@ const { lazy } = require('@discordjs/util');
|
|
|
4
4
|
const { BaseInteraction } = require('./BaseInteraction.js');
|
|
5
5
|
const { InteractionWebhook } = require('./InteractionWebhook.js');
|
|
6
6
|
const { InteractionResponses } = require('./interfaces/InteractionResponses.js');
|
|
7
|
-
const { findComponentByCustomId } = require('../util/Components.js');
|
|
8
7
|
|
|
9
8
|
const getMessage = lazy(() => require('./Message.js').Message);
|
|
10
9
|
|
|
@@ -80,11 +79,13 @@ class MessageComponentInteraction extends BaseInteraction {
|
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* The component which was interacted with
|
|
83
|
-
* @type {MessageActionRowComponent|
|
|
82
|
+
* @type {MessageActionRowComponent|APIMessageActionRowComponent}
|
|
84
83
|
* @readonly
|
|
85
84
|
*/
|
|
86
85
|
get component() {
|
|
87
|
-
return
|
|
86
|
+
return this.message.components
|
|
87
|
+
.flatMap(row => row.components)
|
|
88
|
+
.find(component => (component.customId ?? component.custom_id) === this.customId);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
|
@@ -217,8 +217,7 @@ class MessagePayload {
|
|
|
217
217
|
components,
|
|
218
218
|
username,
|
|
219
219
|
avatar_url: avatarURL,
|
|
220
|
-
allowed_mentions:
|
|
221
|
-
this.isMessage() && this.target.author.id !== this.target.client.user.id ? undefined : allowedMentions,
|
|
220
|
+
allowed_mentions: content === undefined && message_reference === undefined ? undefined : allowedMentions,
|
|
222
221
|
flags,
|
|
223
222
|
message_reference,
|
|
224
223
|
attachments: this.options.attachments,
|
|
@@ -77,11 +77,8 @@ class TextBasedChannel {
|
|
|
77
77
|
* (see {@link https://discord.com/developers/docs/resources/message#allowed-mentions-object here} for more details)
|
|
78
78
|
* @property {Array<(AttachmentBuilder|Attachment|AttachmentPayload|BufferResolvable)>} [files]
|
|
79
79
|
* The files to send with the message.
|
|
80
|
-
* @property {Array<(ActionRowBuilder|
|
|
81
|
-
* Action rows containing interactive components for the message (buttons, select menus)
|
|
82
|
-
* top-level components.
|
|
83
|
-
* <info>When using components v2, the flag {@link MessageFlags.IsComponentsV2} needs to be set
|
|
84
|
-
* and `content`, `embeds`, `stickers`, and `poll` cannot be used.</info>
|
|
80
|
+
* @property {Array<(ActionRowBuilder|ActionRow|APIActionRowComponent)>} [components]
|
|
81
|
+
* Action rows containing interactive components for the message (buttons, select menus)
|
|
85
82
|
*/
|
|
86
83
|
|
|
87
84
|
/**
|
|
@@ -101,9 +98,7 @@ class TextBasedChannel {
|
|
|
101
98
|
* that message will be returned and no new message will be created
|
|
102
99
|
* @property {StickerResolvable[]} [stickers=[]] The stickers to send in the message
|
|
103
100
|
* @property {MessageFlags} [flags] Which flags to set for the message.
|
|
104
|
-
* <info>Only
|
|
105
|
-
* {@link MessageFlags.IsComponentsV2} can be set.</info>
|
|
106
|
-
* <info>{@link MessageFlags.IsComponentsV2} is required if passing components that aren't action rows</info>
|
|
101
|
+
* <info>Only `MessageFlags.SuppressEmbeds` and `MessageFlags.SuppressNotifications` can be set.</info>
|
|
107
102
|
*/
|
|
108
103
|
|
|
109
104
|
/**
|
package/src/util/APITypes.js
CHANGED
|
@@ -60,11 +60,6 @@
|
|
|
60
60
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIChannelSelectComponent}
|
|
61
61
|
*/
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* @external APIContainerComponent
|
|
65
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIContainerComponent}
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
63
|
/**
|
|
69
64
|
* @external APIEmbed
|
|
70
65
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIEmbed}
|
|
@@ -85,11 +80,6 @@
|
|
|
85
80
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIEmoji}
|
|
86
81
|
*/
|
|
87
82
|
|
|
88
|
-
/**
|
|
89
|
-
* @external APIFileComponent
|
|
90
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIFileComponent}
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
83
|
/**
|
|
94
84
|
* @external APIGuild
|
|
95
85
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIGuild}
|
|
@@ -145,16 +135,6 @@
|
|
|
145
135
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIInteractionGuildMember}
|
|
146
136
|
*/
|
|
147
137
|
|
|
148
|
-
/**
|
|
149
|
-
* @external APIMediaGalleryComponent
|
|
150
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMediaGalleryComponent}
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @external APIMediaGalleryItem
|
|
155
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMediaGalleryItem}
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
138
|
/**
|
|
159
139
|
* @external APIMentionableSelectComponent
|
|
160
140
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMentionableSelectComponent}
|
|
@@ -166,8 +146,8 @@
|
|
|
166
146
|
*/
|
|
167
147
|
|
|
168
148
|
/**
|
|
169
|
-
* @external
|
|
170
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#
|
|
149
|
+
* @external APIMessageActionRowComponent
|
|
150
|
+
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMessageActionRowComponent}
|
|
171
151
|
*/
|
|
172
152
|
|
|
173
153
|
/**
|
|
@@ -185,11 +165,6 @@
|
|
|
185
165
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessageInteractionMetadata}
|
|
186
166
|
*/
|
|
187
167
|
|
|
188
|
-
/**
|
|
189
|
-
* @external APIMessageTopLevelComponent
|
|
190
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIMessageTopLevelComponent}
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
168
|
/**
|
|
194
169
|
* @external APIModalInteractionResponse
|
|
195
170
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIModalInteractionResponse}
|
|
@@ -235,11 +210,6 @@
|
|
|
235
210
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISelectMenuOption}
|
|
236
211
|
*/
|
|
237
212
|
|
|
238
|
-
/**
|
|
239
|
-
* @external APISectionComponent
|
|
240
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISectionComponent}
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
213
|
/**
|
|
244
214
|
* @external APISticker
|
|
245
215
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APISticker}
|
|
@@ -255,16 +225,6 @@
|
|
|
255
225
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APITextInputComponent}
|
|
256
226
|
*/
|
|
257
227
|
|
|
258
|
-
/**
|
|
259
|
-
* @external APIThumbnailComponent
|
|
260
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIThumbnailComponent}
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* @external APIUnfurledMediaItem
|
|
265
|
-
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIUnfurledMediaItem}
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
228
|
/**
|
|
269
229
|
* @external APIUser
|
|
270
230
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIUser}
|
package/src/util/Components.js
CHANGED
|
@@ -4,7 +4,6 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} BaseComponentData
|
|
7
|
-
* @property {number} [id] the id of this component
|
|
8
7
|
* @property {ComponentType} type The type of component
|
|
9
8
|
*/
|
|
10
9
|
|
|
@@ -16,30 +15,30 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
16
15
|
/**
|
|
17
16
|
* @typedef {BaseComponentData} ButtonComponentData
|
|
18
17
|
* @property {ButtonStyle} style The style of the button
|
|
19
|
-
* @property {boolean}
|
|
18
|
+
* @property {?boolean} disabled Whether this button is disabled
|
|
20
19
|
* @property {string} label The label of this button
|
|
21
|
-
* @property {APIMessageComponentEmoji}
|
|
22
|
-
* @property {string}
|
|
23
|
-
* @property {string}
|
|
20
|
+
* @property {?APIMessageComponentEmoji} emoji The emoji on this button
|
|
21
|
+
* @property {?string} customId The custom id of the button
|
|
22
|
+
* @property {?string} url The URL of the button
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* @typedef {Object} SelectMenuComponentOptionData
|
|
28
27
|
* @property {string} label The label of the option
|
|
29
28
|
* @property {string} value The value of the option
|
|
30
|
-
* @property {string}
|
|
31
|
-
* @property {APIMessageComponentEmoji}
|
|
32
|
-
* @property {boolean}
|
|
29
|
+
* @property {?string} description The description of the option
|
|
30
|
+
* @property {?APIMessageComponentEmoji} emoji The emoji on the option
|
|
31
|
+
* @property {?boolean} default Whether this option is selected by default
|
|
33
32
|
*/
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* @typedef {BaseComponentData} SelectMenuComponentData
|
|
37
36
|
* @property {string} customId The custom id of the select menu
|
|
38
|
-
* @property {boolean}
|
|
39
|
-
* @property {number}
|
|
40
|
-
* @property {number}
|
|
41
|
-
* @property {SelectMenuComponentOptionData[]}
|
|
42
|
-
* @property {string}
|
|
37
|
+
* @property {?boolean} disabled Whether the select menu is disabled or not
|
|
38
|
+
* @property {?number} maxValues The maximum amount of options that can be selected
|
|
39
|
+
* @property {?number} minValues The minimum amount of options that can be selected
|
|
40
|
+
* @property {?SelectMenuComponentOptionData[]} options The options in this select menu
|
|
41
|
+
* @property {?string} placeholder The placeholder of the select menu
|
|
43
42
|
*/
|
|
44
43
|
|
|
45
44
|
/**
|
|
@@ -51,81 +50,15 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
51
50
|
* @property {string} customId The custom id of the text input
|
|
52
51
|
* @property {TextInputStyle} style The style of the text input
|
|
53
52
|
* @property {string} label The text that appears on top of the text input field
|
|
54
|
-
* @property {number}
|
|
55
|
-
* @property {number}
|
|
56
|
-
* @property {boolean}
|
|
57
|
-
* @property {string}
|
|
58
|
-
* @property {string}
|
|
53
|
+
* @property {?number} minLength The minimum number of characters that can be entered in the text input
|
|
54
|
+
* @property {?number} maxLength The maximum number of characters that can be entered in the text input
|
|
55
|
+
* @property {?boolean} required Whether or not the text input is required or not
|
|
56
|
+
* @property {?string} value The pre-filled text in the text input
|
|
57
|
+
* @property {?string} placeholder Placeholder for the text input
|
|
59
58
|
*/
|
|
60
59
|
|
|
61
60
|
/**
|
|
62
|
-
* @typedef {
|
|
63
|
-
* @property {string} url The url of this media item. Accepts either http:, https: or attachment: protocol
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @typedef {BaseComponentData} ThumbnailComponentData
|
|
68
|
-
* @property {UnfurledMediaItemData} media The media for the thumbnail
|
|
69
|
-
* @property {string} [description] The description of the thumbnail
|
|
70
|
-
* @property {boolean} [spoiler] Whether the thumbnail should be spoilered
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @typedef {BaseComponentData} FileComponentData
|
|
75
|
-
* @property {UnfurledMediaItemData} file The file media in this component
|
|
76
|
-
* @property {boolean} [spoiler] Whether the file should be spoilered
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @typedef {Object} MediaGalleryItemData
|
|
81
|
-
* @property {UnfurledMediaItemData} media The media for the media gallery item
|
|
82
|
-
* @property {string} [description] The description of the media gallery item
|
|
83
|
-
* @property {boolean} [spoiler] Whether the media gallery item should be spoilered
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @typedef {BaseComponentData} MediaGalleryComponentData
|
|
88
|
-
* @property {MediaGalleryItemData[]} items The media gallery items in this media gallery component
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @typedef {BaseComponentData} SeparatorComponentData
|
|
93
|
-
* @property {SeparatorSpacingSize} [spacing] The spacing size of this component
|
|
94
|
-
* @property {boolean} [divider] Whether the separator shows as a divider
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @typedef {BaseComponentData} SectionComponentData
|
|
99
|
-
* @property {Components[]} components The components in this section
|
|
100
|
-
* @property {ButtonComponentData|ThumbnailComponentData} accessory The accessory shown next to this section
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @typedef {BaseComponentData} TextDisplayComponentData
|
|
105
|
-
* @property {string} content The content displayed in this component
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @typedef {ActionRowData|FileComponentData|MediaGalleryComponentData|SectionComponentData|
|
|
110
|
-
* SeparatorComponentData|TextDisplayComponentData} ComponentInContainerData
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @typedef {BaseComponentData} ContainerComponentData
|
|
115
|
-
* @property {ComponentInContainerData} components The components in this container
|
|
116
|
-
* @property {?number} [accentColor] The accent color of this container
|
|
117
|
-
* @property {boolean} [spoiler] Whether the container should be spoilered
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData|TextInputComponentData|
|
|
122
|
-
* ThumbnailComponentData|FileComponentData|MediaGalleryComponentData|SeparatorComponentData|
|
|
123
|
-
* SectionComponentData|TextDisplayComponentData|ContainerComponentData} ComponentData
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @typedef {ActionRow|ContainerComponent|FileComponent|MediaGalleryComponent|
|
|
128
|
-
* SectionComponent|SeparatorComponent|TextDisplayComponent} MessageTopLevelComponent
|
|
61
|
+
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData|TextInputComponentData} ComponentData
|
|
129
62
|
*/
|
|
130
63
|
|
|
131
64
|
/**
|
|
@@ -156,64 +89,19 @@ function createComponent(data) {
|
|
|
156
89
|
return new MentionableSelectMenuComponent(data);
|
|
157
90
|
case ComponentType.ChannelSelect:
|
|
158
91
|
return new ChannelSelectMenuComponent(data);
|
|
159
|
-
case ComponentType.Container:
|
|
160
|
-
return new ContainerComponent(data);
|
|
161
|
-
case ComponentType.TextDisplay:
|
|
162
|
-
return new TextDisplayComponent(data);
|
|
163
|
-
case ComponentType.File:
|
|
164
|
-
return new FileComponent(data);
|
|
165
|
-
case ComponentType.MediaGallery:
|
|
166
|
-
return new MediaGalleryComponent(data);
|
|
167
|
-
case ComponentType.Section:
|
|
168
|
-
return new SectionComponent(data);
|
|
169
|
-
case ComponentType.Separator:
|
|
170
|
-
return new SeparatorComponent(data);
|
|
171
|
-
case ComponentType.Thumbnail:
|
|
172
|
-
return new ThumbnailComponent(data);
|
|
173
92
|
default:
|
|
174
93
|
return new Component(data);
|
|
175
94
|
}
|
|
176
95
|
}
|
|
177
96
|
|
|
178
|
-
/**
|
|
179
|
-
* Finds a component by customId in nested components
|
|
180
|
-
* @param {Array<Component|APIMessageComponent>} components The components to search in
|
|
181
|
-
* @param {string} customId The customId to search for
|
|
182
|
-
* @returns {Component|APIMessageComponent}
|
|
183
|
-
*/
|
|
184
|
-
function findComponentByCustomId(components, customId) {
|
|
185
|
-
return (
|
|
186
|
-
components
|
|
187
|
-
.flatMap(component => {
|
|
188
|
-
switch (component.type) {
|
|
189
|
-
case ComponentType.ActionRow:
|
|
190
|
-
return component.components;
|
|
191
|
-
case ComponentType.Section:
|
|
192
|
-
return [...component.components, component.accessory];
|
|
193
|
-
default:
|
|
194
|
-
return [component];
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
.find(component => (component.customId ?? component.custom_id) === customId) ?? null
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
97
|
exports.createComponent = createComponent;
|
|
202
|
-
exports.findComponentByCustomId = findComponentByCustomId;
|
|
203
98
|
|
|
204
99
|
const { ActionRow } = require('../structures/ActionRow.js');
|
|
205
100
|
const { ButtonComponent } = require('../structures/ButtonComponent.js');
|
|
206
101
|
const { ChannelSelectMenuComponent } = require('../structures/ChannelSelectMenuComponent.js');
|
|
207
102
|
const { Component } = require('../structures/Component.js');
|
|
208
|
-
const { ContainerComponent } = require('../structures/ContainerComponent.js');
|
|
209
|
-
const { FileComponent } = require('../structures/FileComponent.js');
|
|
210
|
-
const { MediaGalleryComponent } = require('../structures/MediaGalleryComponent.js');
|
|
211
103
|
const { MentionableSelectMenuComponent } = require('../structures/MentionableSelectMenuComponent.js');
|
|
212
104
|
const { RoleSelectMenuComponent } = require('../structures/RoleSelectMenuComponent.js');
|
|
213
|
-
const { SectionComponent } = require('../structures/SectionComponent.js');
|
|
214
|
-
const { SeparatorComponent } = require('../structures/SeparatorComponent.js');
|
|
215
105
|
const { StringSelectMenuComponent } = require('../structures/StringSelectMenuComponent.js');
|
|
216
|
-
const { TextDisplayComponent } = require('../structures/TextDisplayComponent.js');
|
|
217
106
|
const { TextInputComponent } = require('../structures/TextInputComponent.js');
|
|
218
|
-
const { ThumbnailComponent } = require('../structures/ThumbnailComponent.js');
|
|
219
107
|
const { UserSelectMenuComponent } = require('../structures/UserSelectMenuComponent.js');
|