discord.js 15.0.0-djs-file-upload.1761302390-5ae769c9e → 15.0.0-move-client-init.1761650119-a4c0a246f
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 +9 -9
- package/src/client/Client.js +3 -10
- package/src/client/websocket/handlers/READY.js +4 -0
- package/src/structures/CommandInteraction.js +1 -1
- package/src/structures/ModalComponentResolver.js +0 -11
- package/src/structures/ModalSubmitInteraction.js +2 -19
- package/src/util/Components.js +1 -9
- package/typings/index.d.mts +2 -19
- package/typings/index.d.ts +2 -19
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-move-client-init.1761650119-a4c0a246f",
|
|
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/
|
|
67
|
-
"@discordjs/
|
|
68
|
-
"@discordjs/
|
|
69
|
-
"@discordjs/ws": "^3.0.0-
|
|
64
|
+
"@discordjs/builders": "^2.0.0-move-client-init.1761650119-a4c0a246f",
|
|
65
|
+
"@discordjs/collection": "^3.0.0-move-client-init.1761650119-a4c0a246f",
|
|
66
|
+
"@discordjs/formatters": "^1.0.0-move-client-init.1761650119-a4c0a246f",
|
|
67
|
+
"@discordjs/rest": "^3.0.0-move-client-init.1761650119-a4c0a246f",
|
|
68
|
+
"@discordjs/util": "^2.0.0-move-client-init.1761650119-a4c0a246f",
|
|
69
|
+
"@discordjs/ws": "^3.0.0-move-client-init.1761650119-a4c0a246f"
|
|
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/docgen": "^0.12.1",
|
|
87
|
+
"@discordjs/scripts": "^0.1.0"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=22.12.0"
|
package/src/client/Client.js
CHANGED
|
@@ -346,15 +346,6 @@ class Client extends BaseClient {
|
|
|
346
346
|
);
|
|
347
347
|
this.ws.on(WebSocketShardEvents.Dispatch, this._handlePacket.bind(this));
|
|
348
348
|
|
|
349
|
-
this.ws.on(WebSocketShardEvents.Ready, async data => {
|
|
350
|
-
for (const guild of data.guilds) {
|
|
351
|
-
this.expectedGuilds.add(guild.id);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
this.status = Status.WaitingForGuilds;
|
|
355
|
-
await this._checkReady();
|
|
356
|
-
});
|
|
357
|
-
|
|
358
349
|
this.ws.on(WebSocketShardEvents.HeartbeatComplete, ({ heartbeatAt, latency }, shardId) => {
|
|
359
350
|
this.emit(Events.Debug, `[WS => Shard ${shardId}] Heartbeat acknowledged, latency of ${latency}ms.`);
|
|
360
351
|
this.lastPingTimestamps.set(shardId, heartbeatAt);
|
|
@@ -384,7 +375,9 @@ class Client extends BaseClient {
|
|
|
384
375
|
PacketHandlers[packet.t](this, packet, shardId);
|
|
385
376
|
}
|
|
386
377
|
|
|
387
|
-
if (
|
|
378
|
+
if (packet.t === GatewayDispatchEvents.Ready) {
|
|
379
|
+
await this._checkReady();
|
|
380
|
+
} else if (this.status === Status.WaitingForGuilds && WaitingForGuildEvents.includes(packet.t)) {
|
|
388
381
|
this.expectedGuilds.delete(packet.d.id);
|
|
389
382
|
await this._checkReady();
|
|
390
383
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { ClientApplication } = require('../../../structures/ClientApplication.js');
|
|
4
|
+
const { Status } = require('../../../util/Status.js');
|
|
4
5
|
|
|
5
6
|
let ClientUser;
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@ module.exports = (client, { d: data }, shardId) => {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
for (const guild of data.guilds) {
|
|
18
|
+
client.expectedGuilds.add(guild.id);
|
|
17
19
|
guild.shardId = shardId;
|
|
18
20
|
client.guilds._add(guild);
|
|
19
21
|
}
|
|
@@ -23,4 +25,6 @@ module.exports = (client, { d: data }, shardId) => {
|
|
|
23
25
|
} else {
|
|
24
26
|
client.application = new ClientApplication(client, data.application);
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
client.status = Status.WaitingForGuilds;
|
|
26
30
|
};
|
|
@@ -96,7 +96,6 @@ 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
|
|
100
99
|
*/
|
|
101
100
|
|
|
102
101
|
/**
|
|
@@ -104,6 +103,7 @@ class CommandInteraction extends BaseInteraction {
|
|
|
104
103
|
*
|
|
105
104
|
* @typedef {BaseInteractionResolvedData} CommandInteractionResolvedData
|
|
106
105
|
* @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,17 +222,6 @@ 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
|
-
}
|
|
236
225
|
}
|
|
237
226
|
|
|
238
227
|
exports.ModalComponentResolver = ModalComponentResolver;
|
|
@@ -9,7 +9,6 @@ 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);
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* @typedef {Object} BaseModalData
|
|
@@ -27,13 +26,6 @@ const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
|
27
26
|
* @property {Collection<string, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
28
27
|
*/
|
|
29
28
|
|
|
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
|
-
|
|
37
29
|
/**
|
|
38
30
|
* @typedef {BaseModalData} TextInputModalData
|
|
39
31
|
* @property {string} customId The custom id of the component
|
|
@@ -45,7 +37,7 @@ const getAttachment = lazy(() => require('./Attachment.js').Attachment);
|
|
|
45
37
|
*/
|
|
46
38
|
|
|
47
39
|
/**
|
|
48
|
-
* @typedef {SelectMenuModalData|TextInputModalData
|
|
40
|
+
* @typedef {SelectMenuModalData|TextInputModalData} ModalData
|
|
49
41
|
*/
|
|
50
42
|
|
|
51
43
|
/**
|
|
@@ -163,7 +155,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
163
155
|
if (rawComponent.values) {
|
|
164
156
|
data.values = rawComponent.values;
|
|
165
157
|
if (resolved) {
|
|
166
|
-
const { members, users, channels, roles
|
|
158
|
+
const { members, users, channels, roles } = resolved;
|
|
167
159
|
const valueSet = new Set(rawComponent.values);
|
|
168
160
|
|
|
169
161
|
if (users) {
|
|
@@ -206,15 +198,6 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
206
198
|
}
|
|
207
199
|
}
|
|
208
200
|
}
|
|
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
|
-
}
|
|
218
201
|
}
|
|
219
202
|
}
|
|
220
203
|
|
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
|
|
27
|
+
* RoleSelectMenuComponentData|MentionableSelectMenuComponentData|ChannelSelectMenuComponentData} ComponentInLabelData
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -44,14 +44,6 @@ 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
|
-
|
|
55
47
|
/**
|
|
56
48
|
* @typedef {BaseComponentData} BaseSelectMenuComponentData
|
|
57
49
|
* @property {string} customId The custom id of the select menu
|
package/typings/index.d.mts
CHANGED
|
@@ -274,13 +274,11 @@ export interface ActionRowData<ComponentType extends ActionRowComponentData | JS
|
|
|
274
274
|
|
|
275
275
|
export type ComponentInLabelData =
|
|
276
276
|
| ChannelSelectMenuComponentData
|
|
277
|
-
| FileUploadComponentData
|
|
278
277
|
| MentionableSelectMenuComponentData
|
|
279
278
|
| RoleSelectMenuComponentData
|
|
280
279
|
| StringSelectMenuComponentData
|
|
281
280
|
| TextInputComponentData
|
|
282
281
|
| UserSelectMenuComponentData;
|
|
283
|
-
|
|
284
282
|
export interface LabelData extends BaseComponentData {
|
|
285
283
|
component: ComponentInLabelData;
|
|
286
284
|
description?: string;
|
|
@@ -2582,12 +2580,7 @@ export interface SelectMenuModalData<Cached extends CacheType = CacheType>
|
|
|
2582
2580
|
values: readonly string[];
|
|
2583
2581
|
}
|
|
2584
2582
|
|
|
2585
|
-
export
|
|
2586
|
-
customId: string;
|
|
2587
|
-
files: readonly Attachment[];
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
export type ModalData = FileUploadModalData | SelectMenuModalData | TextInputModalData;
|
|
2583
|
+
export type ModalData = SelectMenuModalData | TextInputModalData;
|
|
2591
2584
|
|
|
2592
2585
|
export interface LabelModalData extends BaseModalData<ComponentType.Label> {
|
|
2593
2586
|
component: readonly ModalData[];
|
|
@@ -2660,8 +2653,6 @@ export class ModalComponentResolver<Cached extends CacheType = CacheType> {
|
|
|
2660
2653
|
|
|
2661
2654
|
public getSelectedMentionables(customId: string, required: true): ModalSelectedMentionables<Cached>;
|
|
2662
2655
|
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;
|
|
2665
2656
|
}
|
|
2666
2657
|
|
|
2667
2658
|
export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
|
|
@@ -5630,7 +5621,6 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
|
|
|
5630
5621
|
}
|
|
5631
5622
|
|
|
5632
5623
|
export interface BaseInteractionResolvedData<Cached extends CacheType = CacheType> {
|
|
5633
|
-
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5634
5624
|
channels?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Channel, APIInteractionDataResolvedChannel>>;
|
|
5635
5625
|
members?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>>;
|
|
5636
5626
|
roles?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
|
|
@@ -5639,6 +5629,7 @@ export interface BaseInteractionResolvedData<Cached extends CacheType = CacheTyp
|
|
|
5639
5629
|
|
|
5640
5630
|
export interface CommandInteractionResolvedData<Cached extends CacheType = CacheType>
|
|
5641
5631
|
extends BaseInteractionResolvedData<Cached> {
|
|
5632
|
+
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5642
5633
|
messages?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
|
5643
5634
|
}
|
|
5644
5635
|
|
|
@@ -6847,14 +6838,6 @@ export interface TextInputComponentData extends BaseComponentData {
|
|
|
6847
6838
|
value?: string;
|
|
6848
6839
|
}
|
|
6849
6840
|
|
|
6850
|
-
export interface FileUploadComponentData extends BaseComponentData {
|
|
6851
|
-
customId: string;
|
|
6852
|
-
maxValues?: number;
|
|
6853
|
-
minValues?: number;
|
|
6854
|
-
required?: number;
|
|
6855
|
-
type: ComponentType.FileUpload;
|
|
6856
|
-
}
|
|
6857
|
-
|
|
6858
6841
|
export type MessageTarget =
|
|
6859
6842
|
| ChannelManager
|
|
6860
6843
|
| Interaction
|
package/typings/index.d.ts
CHANGED
|
@@ -274,13 +274,11 @@ export interface ActionRowData<ComponentType extends ActionRowComponentData | JS
|
|
|
274
274
|
|
|
275
275
|
export type ComponentInLabelData =
|
|
276
276
|
| ChannelSelectMenuComponentData
|
|
277
|
-
| FileUploadComponentData
|
|
278
277
|
| MentionableSelectMenuComponentData
|
|
279
278
|
| RoleSelectMenuComponentData
|
|
280
279
|
| StringSelectMenuComponentData
|
|
281
280
|
| TextInputComponentData
|
|
282
281
|
| UserSelectMenuComponentData;
|
|
283
|
-
|
|
284
282
|
export interface LabelData extends BaseComponentData {
|
|
285
283
|
component: ComponentInLabelData;
|
|
286
284
|
description?: string;
|
|
@@ -2582,12 +2580,7 @@ export interface SelectMenuModalData<Cached extends CacheType = CacheType>
|
|
|
2582
2580
|
values: readonly string[];
|
|
2583
2581
|
}
|
|
2584
2582
|
|
|
2585
|
-
export
|
|
2586
|
-
customId: string;
|
|
2587
|
-
files: readonly Attachment[];
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
export type ModalData = FileUploadModalData | SelectMenuModalData | TextInputModalData;
|
|
2583
|
+
export type ModalData = SelectMenuModalData | TextInputModalData;
|
|
2591
2584
|
|
|
2592
2585
|
export interface LabelModalData extends BaseModalData<ComponentType.Label> {
|
|
2593
2586
|
component: readonly ModalData[];
|
|
@@ -2660,8 +2653,6 @@ export class ModalComponentResolver<Cached extends CacheType = CacheType> {
|
|
|
2660
2653
|
|
|
2661
2654
|
public getSelectedMentionables(customId: string, required: true): ModalSelectedMentionables<Cached>;
|
|
2662
2655
|
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;
|
|
2665
2656
|
}
|
|
2666
2657
|
|
|
2667
2658
|
export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
|
|
@@ -5630,7 +5621,6 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
|
|
|
5630
5621
|
}
|
|
5631
5622
|
|
|
5632
5623
|
export interface BaseInteractionResolvedData<Cached extends CacheType = CacheType> {
|
|
5633
|
-
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5634
5624
|
channels?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Channel, APIInteractionDataResolvedChannel>>;
|
|
5635
5625
|
members?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>>;
|
|
5636
5626
|
roles?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
|
|
@@ -5639,6 +5629,7 @@ export interface BaseInteractionResolvedData<Cached extends CacheType = CacheTyp
|
|
|
5639
5629
|
|
|
5640
5630
|
export interface CommandInteractionResolvedData<Cached extends CacheType = CacheType>
|
|
5641
5631
|
extends BaseInteractionResolvedData<Cached> {
|
|
5632
|
+
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
5642
5633
|
messages?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
|
5643
5634
|
}
|
|
5644
5635
|
|
|
@@ -6847,14 +6838,6 @@ export interface TextInputComponentData extends BaseComponentData {
|
|
|
6847
6838
|
value?: string;
|
|
6848
6839
|
}
|
|
6849
6840
|
|
|
6850
|
-
export interface FileUploadComponentData extends BaseComponentData {
|
|
6851
|
-
customId: string;
|
|
6852
|
-
maxValues?: number;
|
|
6853
|
-
minValues?: number;
|
|
6854
|
-
required?: number;
|
|
6855
|
-
type: ComponentType.FileUpload;
|
|
6856
|
-
}
|
|
6857
|
-
|
|
6858
6841
|
export type MessageTarget =
|
|
6859
6842
|
| ChannelManager
|
|
6860
6843
|
| Interaction
|