discord.js 15.0.0-dev.1761177718-886d4a7fc → 15.0.0-djs-file-upload.1761302390-5ae769c9e
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
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-
|
|
4
|
+
"version": "15.0.0-djs-file-upload.1761302390-5ae769c9e",
|
|
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",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"magic-bytes.js": "^1.12.1",
|
|
62
62
|
"tslib": "^2.8.1",
|
|
63
63
|
"undici": "7.16.0",
|
|
64
|
-
"@discordjs/
|
|
65
|
-
"@discordjs/
|
|
66
|
-
"@discordjs/rest": "^3.0.0-
|
|
67
|
-
"@discordjs/util": "^2.0.0-
|
|
68
|
-
"@discordjs/formatters": "^1.0.0-
|
|
69
|
-
"@discordjs/ws": "^3.0.0-
|
|
64
|
+
"@discordjs/collection": "^3.0.0-djs-file-upload.1761302390-5ae769c9e",
|
|
65
|
+
"@discordjs/builders": "^2.0.0-djs-file-upload.1761302390-5ae769c9e",
|
|
66
|
+
"@discordjs/rest": "^3.0.0-djs-file-upload.1761302390-5ae769c9e",
|
|
67
|
+
"@discordjs/util": "^2.0.0-djs-file-upload.1761302390-5ae769c9e",
|
|
68
|
+
"@discordjs/formatters": "^1.0.0-djs-file-upload.1761302390-5ae769c9e",
|
|
69
|
+
"@discordjs/ws": "^3.0.0-djs-file-upload.1761302390-5ae769c9e"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@favware/cliff-jumper": "^4.1.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"turbo": "^2.5.8",
|
|
84
84
|
"typescript": "~5.9.3",
|
|
85
85
|
"@discordjs/api-extractor": "^7.52.7",
|
|
86
|
-
"@discordjs/
|
|
87
|
-
"@discordjs/
|
|
86
|
+
"@discordjs/scripts": "^0.1.0",
|
|
87
|
+
"@discordjs/docgen": "^0.12.1"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=22.12.0"
|
|
@@ -96,6 +96,7 @@ class CommandInteraction extends BaseInteraction {
|
|
|
96
96
|
* @property {Collection<Snowflake, GuildMember|APIGuildMember>} [members] The resolved guild members
|
|
97
97
|
* @property {Collection<Snowflake, Role|APIRole>} [roles] The resolved roles
|
|
98
98
|
* @property {Collection<Snowflake, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
99
|
+
* @property {Collection<Snowflake, Attachment>} [attachments] The resolved attachments
|
|
99
100
|
*/
|
|
100
101
|
|
|
101
102
|
/**
|
|
@@ -103,7 +104,6 @@ class CommandInteraction extends BaseInteraction {
|
|
|
103
104
|
*
|
|
104
105
|
* @typedef {BaseInteractionResolvedData} CommandInteractionResolvedData
|
|
105
106
|
* @property {Collection<Snowflake, Message|APIMessage>} [messages] The resolved messages
|
|
106
|
-
* @property {Collection<Snowflake, Attachment>} [attachments] The resolved attachments
|
|
107
107
|
*/
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -222,6 +222,17 @@ class ModalComponentResolver {
|
|
|
222
222
|
|
|
223
223
|
return null;
|
|
224
224
|
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Gets file upload component
|
|
228
|
+
*
|
|
229
|
+
* @param {string} customId The custom id of the component
|
|
230
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
231
|
+
* @returns {?Collection<string, Attachment>} The uploaded files, or null if none were uploaded and not required
|
|
232
|
+
*/
|
|
233
|
+
getUploadedFiles(customId, required = false) {
|
|
234
|
+
return this._getTypedComponent(customId, [ComponentType.FileUpload], ['attachments'], required).attachments ?? null;
|
|
235
|
+
}
|
|
225
236
|
}
|
|
226
237
|
|
|
227
238
|
exports.ModalComponentResolver = ModalComponentResolver;
|
|
@@ -9,6 +9,7 @@ const { ModalComponentResolver } = require('./ModalComponentResolver.js');
|
|
|
9
9
|
const { InteractionResponses } = require('./interfaces/InteractionResponses.js');
|
|
10
10
|
|
|
11
11
|
const getMessage = lazy(() => require('./Message.js').Message);
|
|
12
|
+
const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {Object} BaseModalData
|
|
@@ -26,6 +27,13 @@ const getMessage = lazy(() => require('./Message.js').Message);
|
|
|
26
27
|
* @property {Collection<string, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
27
28
|
*/
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {BaseModalData} FileUploadModalData
|
|
32
|
+
* @property {string} customId The custom id of the file upload
|
|
33
|
+
* @property {string[]} values The values of the file upload
|
|
34
|
+
* @property {Collection<string, Attachment>} [attachments] The resolved attachments
|
|
35
|
+
*/
|
|
36
|
+
|
|
29
37
|
/**
|
|
30
38
|
* @typedef {BaseModalData} TextInputModalData
|
|
31
39
|
* @property {string} customId The custom id of the component
|
|
@@ -37,7 +45,7 @@ const getMessage = lazy(() => require('./Message.js').Message);
|
|
|
37
45
|
*/
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
|
-
* @typedef {SelectMenuModalData|TextInputModalData} ModalData
|
|
48
|
+
* @typedef {SelectMenuModalData|TextInputModalData|FileUploadModalData} ModalData
|
|
41
49
|
*/
|
|
42
50
|
|
|
43
51
|
/**
|
|
@@ -155,7 +163,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
155
163
|
if (rawComponent.values) {
|
|
156
164
|
data.values = rawComponent.values;
|
|
157
165
|
if (resolved) {
|
|
158
|
-
const { members, users, channels, roles } = resolved;
|
|
166
|
+
const { members, users, channels, roles, attachments } = resolved;
|
|
159
167
|
const valueSet = new Set(rawComponent.values);
|
|
160
168
|
|
|
161
169
|
if (users) {
|
|
@@ -198,6 +206,15 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
198
206
|
}
|
|
199
207
|
}
|
|
200
208
|
}
|
|
209
|
+
|
|
210
|
+
if (attachments) {
|
|
211
|
+
data.attachments = new Collection();
|
|
212
|
+
for (const [id, attachment] of Object.entries(attachments)) {
|
|
213
|
+
if (valueSet.has(id)) {
|
|
214
|
+
data.attachments.set(id, new (getAttachment())(attachment));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
201
218
|
}
|
|
202
219
|
}
|
|
203
220
|
|
package/src/util/Components.js
CHANGED
|
@@ -24,7 +24,7 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @typedef {StringSelectMenuComponentData|TextInputComponentData|UserSelectMenuComponentData|
|
|
27
|
-
* RoleSelectMenuComponentData|MentionableSelectMenuComponentData|ChannelSelectMenuComponentData} ComponentInLabelData
|
|
27
|
+
* RoleSelectMenuComponentData|MentionableSelectMenuComponentData|ChannelSelectMenuComponentData|FileUploadComponentData} ComponentInLabelData
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -44,6 +44,14 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
44
44
|
* @property {string} [url] The URL of the button
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {BaseComponentData} FileUploadComponentData
|
|
49
|
+
* @property {string} customId The custom id of the file upload
|
|
50
|
+
* @property {number} [minValues] The minimum number of files that can be uploaded (0-10)
|
|
51
|
+
* @property {number} [maxValues] The maximum number of files that can be uploaded (1-10)
|
|
52
|
+
* @property {boolean} [required] Whether this component is required in modals
|
|
53
|
+
*/
|
|
54
|
+
|
|
47
55
|
/**
|
|
48
56
|
* @typedef {BaseComponentData} BaseSelectMenuComponentData
|
|
49
57
|
* @property {string} customId The custom id of the select menu
|
package/typings/index.d.mts
CHANGED
|
@@ -274,11 +274,13 @@ export interface ActionRowData<ComponentType extends ActionRowComponentData | JS
|
|
|
274
274
|
|
|
275
275
|
export type ComponentInLabelData =
|
|
276
276
|
| ChannelSelectMenuComponentData
|
|
277
|
+
| FileUploadComponentData
|
|
277
278
|
| MentionableSelectMenuComponentData
|
|
278
279
|
| RoleSelectMenuComponentData
|
|
279
280
|
| StringSelectMenuComponentData
|
|
280
281
|
| TextInputComponentData
|
|
281
282
|
| UserSelectMenuComponentData;
|
|
283
|
+
|
|
282
284
|
export interface LabelData extends BaseComponentData {
|
|
283
285
|
component: ComponentInLabelData;
|
|
284
286
|
description?: string;
|
|
@@ -2580,7 +2582,12 @@ export interface SelectMenuModalData<Cached extends CacheType = CacheType>
|
|
|
2580
2582
|
values: readonly string[];
|
|
2581
2583
|
}
|
|
2582
2584
|
|
|
2583
|
-
export
|
|
2585
|
+
export interface FileUploadModalData extends BaseModalData<ComponentType.FileUpload> {
|
|
2586
|
+
customId: string;
|
|
2587
|
+
files: readonly Attachment[];
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
export type ModalData = FileUploadModalData | SelectMenuModalData | TextInputModalData;
|
|
2584
2591
|
|
|
2585
2592
|
export interface LabelModalData extends BaseModalData<ComponentType.Label> {
|
|
2586
2593
|
component: readonly ModalData[];
|
|
@@ -2653,6 +2660,8 @@ export class ModalComponentResolver<Cached extends CacheType = CacheType> {
|
|
|
2653
2660
|
|
|
2654
2661
|
public getSelectedMentionables(customId: string, required: true): ModalSelectedMentionables<Cached>;
|
|
2655
2662
|
public getSelectedMentionables(customId: string, required?: boolean): ModalSelectedMentionables<Cached> | null;
|
|
2663
|
+
public getUploadedFiles(customId: string, required: true): ReadonlyCollection<string, Attachment>;
|
|
2664
|
+
public getUploadedFiles(customId: string, required?: boolean): ReadonlyCollection<string, Attachment> | null;
|
|
2656
2665
|
}
|
|
2657
2666
|
|
|
2658
2667
|
export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
|
|
@@ -5621,6 +5630,7 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
|
|
|
5621
5630
|
}
|
|
5622
5631
|
|
|
5623
5632
|
export interface BaseInteractionResolvedData<Cached extends CacheType = CacheType> {
|
|
5633
|
+
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5624
5634
|
channels?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Channel, APIInteractionDataResolvedChannel>>;
|
|
5625
5635
|
members?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>>;
|
|
5626
5636
|
roles?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
|
|
@@ -5629,7 +5639,6 @@ export interface BaseInteractionResolvedData<Cached extends CacheType = CacheTyp
|
|
|
5629
5639
|
|
|
5630
5640
|
export interface CommandInteractionResolvedData<Cached extends CacheType = CacheType>
|
|
5631
5641
|
extends BaseInteractionResolvedData<Cached> {
|
|
5632
|
-
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5633
5642
|
messages?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
|
5634
5643
|
}
|
|
5635
5644
|
|
|
@@ -6838,6 +6847,14 @@ export interface TextInputComponentData extends BaseComponentData {
|
|
|
6838
6847
|
value?: string;
|
|
6839
6848
|
}
|
|
6840
6849
|
|
|
6850
|
+
export interface FileUploadComponentData extends BaseComponentData {
|
|
6851
|
+
customId: string;
|
|
6852
|
+
maxValues?: number;
|
|
6853
|
+
minValues?: number;
|
|
6854
|
+
required?: number;
|
|
6855
|
+
type: ComponentType.FileUpload;
|
|
6856
|
+
}
|
|
6857
|
+
|
|
6841
6858
|
export type MessageTarget =
|
|
6842
6859
|
| ChannelManager
|
|
6843
6860
|
| Interaction
|
package/typings/index.d.ts
CHANGED
|
@@ -274,11 +274,13 @@ export interface ActionRowData<ComponentType extends ActionRowComponentData | JS
|
|
|
274
274
|
|
|
275
275
|
export type ComponentInLabelData =
|
|
276
276
|
| ChannelSelectMenuComponentData
|
|
277
|
+
| FileUploadComponentData
|
|
277
278
|
| MentionableSelectMenuComponentData
|
|
278
279
|
| RoleSelectMenuComponentData
|
|
279
280
|
| StringSelectMenuComponentData
|
|
280
281
|
| TextInputComponentData
|
|
281
282
|
| UserSelectMenuComponentData;
|
|
283
|
+
|
|
282
284
|
export interface LabelData extends BaseComponentData {
|
|
283
285
|
component: ComponentInLabelData;
|
|
284
286
|
description?: string;
|
|
@@ -2580,7 +2582,12 @@ export interface SelectMenuModalData<Cached extends CacheType = CacheType>
|
|
|
2580
2582
|
values: readonly string[];
|
|
2581
2583
|
}
|
|
2582
2584
|
|
|
2583
|
-
export
|
|
2585
|
+
export interface FileUploadModalData extends BaseModalData<ComponentType.FileUpload> {
|
|
2586
|
+
customId: string;
|
|
2587
|
+
files: readonly Attachment[];
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
export type ModalData = FileUploadModalData | SelectMenuModalData | TextInputModalData;
|
|
2584
2591
|
|
|
2585
2592
|
export interface LabelModalData extends BaseModalData<ComponentType.Label> {
|
|
2586
2593
|
component: readonly ModalData[];
|
|
@@ -2653,6 +2660,8 @@ export class ModalComponentResolver<Cached extends CacheType = CacheType> {
|
|
|
2653
2660
|
|
|
2654
2661
|
public getSelectedMentionables(customId: string, required: true): ModalSelectedMentionables<Cached>;
|
|
2655
2662
|
public getSelectedMentionables(customId: string, required?: boolean): ModalSelectedMentionables<Cached> | null;
|
|
2663
|
+
public getUploadedFiles(customId: string, required: true): ReadonlyCollection<string, Attachment>;
|
|
2664
|
+
public getUploadedFiles(customId: string, required?: boolean): ReadonlyCollection<string, Attachment> | null;
|
|
2656
2665
|
}
|
|
2657
2666
|
|
|
2658
2667
|
export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
|
|
@@ -5621,6 +5630,7 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
|
|
|
5621
5630
|
}
|
|
5622
5631
|
|
|
5623
5632
|
export interface BaseInteractionResolvedData<Cached extends CacheType = CacheType> {
|
|
5633
|
+
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5624
5634
|
channels?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Channel, APIInteractionDataResolvedChannel>>;
|
|
5625
5635
|
members?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>>;
|
|
5626
5636
|
roles?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
|
|
@@ -5629,7 +5639,6 @@ export interface BaseInteractionResolvedData<Cached extends CacheType = CacheTyp
|
|
|
5629
5639
|
|
|
5630
5640
|
export interface CommandInteractionResolvedData<Cached extends CacheType = CacheType>
|
|
5631
5641
|
extends BaseInteractionResolvedData<Cached> {
|
|
5632
|
-
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5633
5642
|
messages?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
|
5634
5643
|
}
|
|
5635
5644
|
|
|
@@ -6838,6 +6847,14 @@ export interface TextInputComponentData extends BaseComponentData {
|
|
|
6838
6847
|
value?: string;
|
|
6839
6848
|
}
|
|
6840
6849
|
|
|
6850
|
+
export interface FileUploadComponentData extends BaseComponentData {
|
|
6851
|
+
customId: string;
|
|
6852
|
+
maxValues?: number;
|
|
6853
|
+
minValues?: number;
|
|
6854
|
+
required?: number;
|
|
6855
|
+
type: ComponentType.FileUpload;
|
|
6856
|
+
}
|
|
6857
|
+
|
|
6841
6858
|
export type MessageTarget =
|
|
6842
6859
|
| ChannelManager
|
|
6843
6860
|
| Interaction
|