discord.js 14.23.2 → 14.24.0
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 +5 -5
- package/src/structures/CommandInteraction.js +1 -1
- package/src/structures/Message.js +11 -5
- package/src/structures/ModalSubmitFields.js +11 -0
- package/src/structures/ModalSubmitInteraction.js +19 -2
- package/src/util/Components.js +10 -1
- package/typings/index.d.mts +19 -3
- package/typings/index.d.ts +19 -3
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": "14.
|
|
4
|
+
"version": "14.24.0",
|
|
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",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"homepage": "https://discord.js.org",
|
|
54
54
|
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@discordjs/builders": "^1.
|
|
56
|
+
"@discordjs/builders": "^1.13.0",
|
|
57
57
|
"@discordjs/collection": "1.5.3",
|
|
58
58
|
"@discordjs/formatters": "^0.6.1",
|
|
59
59
|
"@discordjs/ws": "^1.2.3",
|
|
60
60
|
"@sapphire/snowflake": "3.5.3",
|
|
61
|
-
"discord-api-types": "^0.38.
|
|
61
|
+
"discord-api-types": "^0.38.31",
|
|
62
62
|
"fast-deep-equal": "3.1.3",
|
|
63
63
|
"lodash.snakecase": "4.1.1",
|
|
64
64
|
"magic-bytes.js": "^1.10.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"turbo": "^2.0.14",
|
|
84
84
|
"typescript": "~5.5.4",
|
|
85
85
|
"@discordjs/api-extractor": "^7.38.1",
|
|
86
|
-
"@discordjs/
|
|
87
|
-
"@discordjs/
|
|
86
|
+
"@discordjs/scripts": "^0.1.0",
|
|
87
|
+
"@discordjs/docgen": "^0.12.1"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=18"
|
|
@@ -85,6 +85,7 @@ class CommandInteraction extends BaseInteraction {
|
|
|
85
85
|
* @property {Collection<Snowflake, GuildMember|APIGuildMember>} [members] The resolved guild members
|
|
86
86
|
* @property {Collection<Snowflake, Role|APIRole>} [roles] The resolved roles
|
|
87
87
|
* @property {Collection<Snowflake, BaseChannel|APIChannel>} [channels] The resolved channels
|
|
88
|
+
* @property {Collection<Snowflake, Attachment>} [attachments] The resolved attachments
|
|
88
89
|
*/
|
|
89
90
|
|
|
90
91
|
/**
|
|
@@ -92,7 +93,6 @@ class CommandInteraction extends BaseInteraction {
|
|
|
92
93
|
*
|
|
93
94
|
* @typedef {BaseInteractionResolvedData} CommandInteractionResolvedData
|
|
94
95
|
* @property {Collection<Snowflake, Message|APIMessage>} [messages] The resolved messages
|
|
95
|
-
* @property {Collection<Snowflake, Attachment>} [attachments] The resolved attachments
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
98
|
/**
|
|
@@ -781,11 +781,17 @@ class Message extends Base {
|
|
|
781
781
|
*/
|
|
782
782
|
get pinnable() {
|
|
783
783
|
const { channel } = this;
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
784
|
+
|
|
785
|
+
if (this.system) return false;
|
|
786
|
+
if (!this.guild) return true;
|
|
787
|
+
if (!channel?.viewable) return false;
|
|
788
|
+
|
|
789
|
+
const permissions = channel?.permissionsFor(this.client.user);
|
|
790
|
+
if (!permissions) return false;
|
|
791
|
+
|
|
792
|
+
return (
|
|
793
|
+
permissions.has([PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.PinMessages]) ||
|
|
794
|
+
permissions.has([PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.ManageMessages])
|
|
789
795
|
);
|
|
790
796
|
}
|
|
791
797
|
|
|
@@ -216,6 +216,17 @@ class ModalSubmitFields {
|
|
|
216
216
|
|
|
217
217
|
return null;
|
|
218
218
|
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Gets file upload component
|
|
222
|
+
*
|
|
223
|
+
* @param {string} customId The custom id of the component
|
|
224
|
+
* @param {boolean} [required=false] Whether to throw an error if the component value is not found or empty
|
|
225
|
+
* @returns {?Collection<Snowflake, Attachment>} The uploaded files, or null if none were uploaded and not required
|
|
226
|
+
*/
|
|
227
|
+
getUploadedFiles(customId, required = false) {
|
|
228
|
+
return this._getTypedComponent(customId, [ComponentType.FileUpload], ['attachments'], required).attachments ?? null;
|
|
229
|
+
}
|
|
219
230
|
}
|
|
220
231
|
|
|
221
232
|
module.exports = ModalSubmitFields;
|
|
@@ -9,6 +9,7 @@ const InteractionResponses = require('./interfaces/InteractionResponses');
|
|
|
9
9
|
const { transformResolved } = require('../util/Util');
|
|
10
10
|
|
|
11
11
|
const getMessage = lazy(() => require('./Message').Message);
|
|
12
|
+
const getAttachment = lazy(() => require('./Attachment'));
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {Object} BaseModalData
|
|
@@ -16,6 +17,13 @@ const getMessage = lazy(() => require('./Message').Message);
|
|
|
16
17
|
* @property {number} id The id of the field
|
|
17
18
|
*/
|
|
18
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {BaseModalData} FileUploadModalData
|
|
22
|
+
* @property {string} customId The custom id of the file upload
|
|
23
|
+
* @property {string[]} values The values of the file upload
|
|
24
|
+
* @property {Collection<string, Attachment>} [attachments] The resolved attachments
|
|
25
|
+
*/
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* @typedef {BaseModalData} TextInputModalData
|
|
21
29
|
* @property {string} customId The custom id of the field
|
|
@@ -37,7 +45,7 @@ const getMessage = lazy(() => require('./Message').Message);
|
|
|
37
45
|
*/
|
|
38
46
|
|
|
39
47
|
/**
|
|
40
|
-
* @typedef {SelectMenuModalData|TextInputModalData} ModalData
|
|
48
|
+
* @typedef {SelectMenuModalData|TextInputModalData|FileUploadModalData} ModalData
|
|
41
49
|
*/
|
|
42
50
|
|
|
43
51
|
/**
|
|
@@ -161,7 +169,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
161
169
|
|
|
162
170
|
/* eslint-disable max-depth */
|
|
163
171
|
if (resolved) {
|
|
164
|
-
const { members, users, channels, roles } = resolved;
|
|
172
|
+
const { members, users, channels, roles, attachments } = resolved;
|
|
165
173
|
const valueSet = new Set(rawComponent.values);
|
|
166
174
|
|
|
167
175
|
if (users) {
|
|
@@ -204,6 +212,15 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|
|
204
212
|
}
|
|
205
213
|
}
|
|
206
214
|
}
|
|
215
|
+
|
|
216
|
+
if (attachments) {
|
|
217
|
+
data.attachments = new Collection();
|
|
218
|
+
for (const [id, attachment] of Object.entries(attachments)) {
|
|
219
|
+
if (valueSet.has(id)) {
|
|
220
|
+
data.attachments.set(id, new (getAttachment())(attachment));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
207
224
|
}
|
|
208
225
|
|
|
209
226
|
/* eslint-enable max-depth */
|
package/src/util/Components.js
CHANGED
|
@@ -23,7 +23,8 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* @typedef {StringSelectMenuComponentData|TextInputComponentData|UserSelectMenuComponentData|
|
|
26
|
-
* RoleSelectMenuComponentData|MentionableSelectMenuComponentData|ChannelSelectMenuComponentData
|
|
26
|
+
* RoleSelectMenuComponentData|MentionableSelectMenuComponentData|ChannelSelectMenuComponentData|
|
|
27
|
+
* FileUploadComponentData} ComponentInLabelData
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -43,6 +44,14 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
43
44
|
* @property {string} [url] The URL of the button
|
|
44
45
|
*/
|
|
45
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
|
+
|
|
46
55
|
/**
|
|
47
56
|
* @typedef {BaseComponentData} BaseSelectMenuComponentData
|
|
48
57
|
* @property {string} customId The custom id of the select menu
|
package/typings/index.d.mts
CHANGED
|
@@ -367,7 +367,8 @@ export type ComponentInLabelData =
|
|
|
367
367
|
| UserSelectMenuComponentData
|
|
368
368
|
| ChannelSelectMenuComponentData
|
|
369
369
|
| RoleSelectMenuComponentData
|
|
370
|
-
| MentionableSelectMenuComponentData
|
|
370
|
+
| MentionableSelectMenuComponentData
|
|
371
|
+
| FileUploadComponentData;
|
|
371
372
|
|
|
372
373
|
export interface LabelComponentData extends BaseComponentData {
|
|
373
374
|
type: ComponentType.Label;
|
|
@@ -2823,7 +2824,12 @@ export interface SelectMenuModalData<Cached extends CacheType = CacheType>
|
|
|
2823
2824
|
values: readonly string[];
|
|
2824
2825
|
}
|
|
2825
2826
|
|
|
2826
|
-
export
|
|
2827
|
+
export interface FileUploadModalData extends BaseModalData<ComponentType.FileUpload> {
|
|
2828
|
+
customId: string;
|
|
2829
|
+
files: readonly Attachment[];
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
export type ModalData = FileUploadModalData | SelectMenuModalData | TextInputModalData;
|
|
2827
2833
|
|
|
2828
2834
|
export interface LabelModalData extends BaseModalData<ComponentType.Label> {
|
|
2829
2835
|
component: readonly ModalData[];
|
|
@@ -2900,6 +2906,8 @@ export class ModalSubmitFields<Cached extends CacheType = CacheType> {
|
|
|
2900
2906
|
|
|
2901
2907
|
public getSelectedMentionables(customId: string, required: true): ModalSelectedMentionables<Cached>;
|
|
2902
2908
|
public getSelectedMentionables(customId: string, required?: boolean): ModalSelectedMentionables<Cached> | null;
|
|
2909
|
+
public getUploadedFiles(customId: string, required: true): ReadonlyCollection<Snowflake, Attachment>;
|
|
2910
|
+
public getUploadedFiles(customId: string, required?: boolean): ReadonlyCollection<Snowflake, Attachment> | null;
|
|
2903
2911
|
}
|
|
2904
2912
|
|
|
2905
2913
|
export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
|
|
@@ -6184,6 +6192,7 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
|
|
|
6184
6192
|
}
|
|
6185
6193
|
|
|
6186
6194
|
export interface BaseInteractionResolvedData<Cached extends CacheType = CacheType> {
|
|
6195
|
+
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
6187
6196
|
channels?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Channel, APIInteractionDataResolvedChannel>>;
|
|
6188
6197
|
members?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>>;
|
|
6189
6198
|
roles?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
|
|
@@ -6192,7 +6201,6 @@ export interface BaseInteractionResolvedData<Cached extends CacheType = CacheTyp
|
|
|
6192
6201
|
|
|
6193
6202
|
export interface CommandInteractionResolvedData<Cached extends CacheType = CacheType>
|
|
6194
6203
|
extends BaseInteractionResolvedData<Cached> {
|
|
6195
|
-
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
6196
6204
|
messages?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
|
6197
6205
|
}
|
|
6198
6206
|
|
|
@@ -7430,6 +7438,14 @@ export interface TextInputComponentData extends BaseComponentData {
|
|
|
7430
7438
|
placeholder?: string;
|
|
7431
7439
|
}
|
|
7432
7440
|
|
|
7441
|
+
export interface FileUploadComponentData extends BaseComponentData {
|
|
7442
|
+
customId: string;
|
|
7443
|
+
maxValues?: number;
|
|
7444
|
+
minValues?: number;
|
|
7445
|
+
required?: number;
|
|
7446
|
+
type: ComponentType.FileUpload;
|
|
7447
|
+
}
|
|
7448
|
+
|
|
7433
7449
|
export type MessageTarget =
|
|
7434
7450
|
| Interaction
|
|
7435
7451
|
| InteractionWebhook
|
package/typings/index.d.ts
CHANGED
|
@@ -367,7 +367,8 @@ export type ComponentInLabelData =
|
|
|
367
367
|
| UserSelectMenuComponentData
|
|
368
368
|
| ChannelSelectMenuComponentData
|
|
369
369
|
| RoleSelectMenuComponentData
|
|
370
|
-
| MentionableSelectMenuComponentData
|
|
370
|
+
| MentionableSelectMenuComponentData
|
|
371
|
+
| FileUploadComponentData;
|
|
371
372
|
|
|
372
373
|
export interface LabelComponentData extends BaseComponentData {
|
|
373
374
|
type: ComponentType.Label;
|
|
@@ -2823,7 +2824,12 @@ export interface SelectMenuModalData<Cached extends CacheType = CacheType>
|
|
|
2823
2824
|
values: readonly string[];
|
|
2824
2825
|
}
|
|
2825
2826
|
|
|
2826
|
-
export
|
|
2827
|
+
export interface FileUploadModalData extends BaseModalData<ComponentType.FileUpload> {
|
|
2828
|
+
customId: string;
|
|
2829
|
+
files: readonly Attachment[];
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
export type ModalData = FileUploadModalData | SelectMenuModalData | TextInputModalData;
|
|
2827
2833
|
|
|
2828
2834
|
export interface LabelModalData extends BaseModalData<ComponentType.Label> {
|
|
2829
2835
|
component: readonly ModalData[];
|
|
@@ -2900,6 +2906,8 @@ export class ModalSubmitFields<Cached extends CacheType = CacheType> {
|
|
|
2900
2906
|
|
|
2901
2907
|
public getSelectedMentionables(customId: string, required: true): ModalSelectedMentionables<Cached>;
|
|
2902
2908
|
public getSelectedMentionables(customId: string, required?: boolean): ModalSelectedMentionables<Cached> | null;
|
|
2909
|
+
public getUploadedFiles(customId: string, required: true): ReadonlyCollection<Snowflake, Attachment>;
|
|
2910
|
+
public getUploadedFiles(customId: string, required?: boolean): ReadonlyCollection<Snowflake, Attachment> | null;
|
|
2903
2911
|
}
|
|
2904
2912
|
|
|
2905
2913
|
export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
|
|
@@ -6184,6 +6192,7 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
|
|
|
6184
6192
|
}
|
|
6185
6193
|
|
|
6186
6194
|
export interface BaseInteractionResolvedData<Cached extends CacheType = CacheType> {
|
|
6195
|
+
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
6187
6196
|
channels?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Channel, APIInteractionDataResolvedChannel>>;
|
|
6188
6197
|
members?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>>;
|
|
6189
6198
|
roles?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
|
|
@@ -6192,7 +6201,6 @@ export interface BaseInteractionResolvedData<Cached extends CacheType = CacheTyp
|
|
|
6192
6201
|
|
|
6193
6202
|
export interface CommandInteractionResolvedData<Cached extends CacheType = CacheType>
|
|
6194
6203
|
extends BaseInteractionResolvedData<Cached> {
|
|
6195
|
-
attachments?: ReadonlyCollection<Snowflake, Attachment>;
|
|
6196
6204
|
messages?: ReadonlyCollection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
|
6197
6205
|
}
|
|
6198
6206
|
|
|
@@ -7430,6 +7438,14 @@ export interface TextInputComponentData extends BaseComponentData {
|
|
|
7430
7438
|
placeholder?: string;
|
|
7431
7439
|
}
|
|
7432
7440
|
|
|
7441
|
+
export interface FileUploadComponentData extends BaseComponentData {
|
|
7442
|
+
customId: string;
|
|
7443
|
+
maxValues?: number;
|
|
7444
|
+
minValues?: number;
|
|
7445
|
+
required?: number;
|
|
7446
|
+
type: ComponentType.FileUpload;
|
|
7447
|
+
}
|
|
7448
|
+
|
|
7433
7449
|
export type MessageTarget =
|
|
7434
7450
|
| Interaction
|
|
7435
7451
|
| InteractionWebhook
|