discord.js 14.19.3 → 14.20.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 +6 -5
- package/src/client/Client.js +0 -1
- package/src/client/actions/InteractionCreate.js +4 -0
- package/src/index.js +1 -0
- package/src/managers/ApplicationCommandManager.js +1 -0
- package/src/managers/ChannelManager.js +7 -0
- package/src/structures/ApplicationCommand.js +21 -3
- package/src/structures/BaseInteraction.js +16 -0
- package/src/structures/CommandInteraction.js +1 -0
- package/src/structures/MessageComponentInteraction.js +1 -0
- package/src/structures/ModalSubmitInteraction.js +1 -0
- package/src/structures/PartialGroupDMChannel.js +2 -2
- package/src/structures/PrimaryEntryPointCommandInteraction.js +11 -0
- package/src/structures/interfaces/InteractionResponses.js +26 -0
- package/src/util/APITypes.js +5 -0
- package/src/util/Components.js +31 -62
- package/src/util/Transformers.js +9 -1
- package/typings/index.d.mts +53 -18
- package/typings/index.d.ts +53 -18
- package/typings/index.test-d.ts +0 -2846
- package/typings/tsdoc-metadata.json +0 -11
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.20.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",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"src",
|
|
26
|
-
"typings"
|
|
26
|
+
"typings/*.d.ts",
|
|
27
|
+
"typings/*.d.mts"
|
|
27
28
|
],
|
|
28
29
|
"contributors": [
|
|
29
30
|
"Crawl <icrawltogo@gmail.com>",
|
|
@@ -55,15 +56,15 @@
|
|
|
55
56
|
"@discordjs/builders": "^1.11.2",
|
|
56
57
|
"@discordjs/collection": "1.5.3",
|
|
57
58
|
"@discordjs/formatters": "^0.6.1",
|
|
58
|
-
"@discordjs/ws": "^1.2.
|
|
59
|
+
"@discordjs/ws": "^1.2.3",
|
|
59
60
|
"@sapphire/snowflake": "3.5.3",
|
|
60
61
|
"discord-api-types": "^0.38.1",
|
|
61
62
|
"fast-deep-equal": "3.1.3",
|
|
62
63
|
"lodash.snakecase": "4.1.1",
|
|
63
64
|
"magic-bytes.js": "^1.10.0",
|
|
64
65
|
"tslib": "^2.6.3",
|
|
65
|
-
"undici": "6.21.
|
|
66
|
-
"@discordjs/rest": "^2.5.
|
|
66
|
+
"undici": "6.21.3",
|
|
67
|
+
"@discordjs/rest": "^2.5.1",
|
|
67
68
|
"@discordjs/util": "^1.1.1"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
package/src/client/Client.js
CHANGED
|
@@ -277,7 +277,6 @@ class Client extends BaseClient {
|
|
|
277
277
|
const code = resolveInviteCode(invite);
|
|
278
278
|
const query = makeURLSearchParams({
|
|
279
279
|
with_counts: true,
|
|
280
|
-
with_expiration: true,
|
|
281
280
|
guild_scheduled_event_id: options?.guildScheduledEventId,
|
|
282
281
|
});
|
|
283
282
|
const data = await this.rest.get(Routes.invite(code), { query });
|
|
@@ -9,6 +9,7 @@ const ChatInputCommandInteraction = require('../../structures/ChatInputCommandIn
|
|
|
9
9
|
const MentionableSelectMenuInteraction = require('../../structures/MentionableSelectMenuInteraction');
|
|
10
10
|
const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction');
|
|
11
11
|
const ModalSubmitInteraction = require('../../structures/ModalSubmitInteraction');
|
|
12
|
+
const PrimaryEntryPointCommandInteraction = require('../../structures/PrimaryEntryPointCommandInteraction');
|
|
12
13
|
const RoleSelectMenuInteraction = require('../../structures/RoleSelectMenuInteraction');
|
|
13
14
|
const StringSelectMenuInteraction = require('../../structures/StringSelectMenuInteraction');
|
|
14
15
|
const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction');
|
|
@@ -38,6 +39,9 @@ class InteractionCreateAction extends Action {
|
|
|
38
39
|
if (channel && !channel.isTextBased()) return;
|
|
39
40
|
InteractionClass = MessageContextMenuCommandInteraction;
|
|
40
41
|
break;
|
|
42
|
+
case ApplicationCommandType.PrimaryEntryPoint:
|
|
43
|
+
InteractionClass = PrimaryEntryPointCommandInteraction;
|
|
44
|
+
break;
|
|
41
45
|
default:
|
|
42
46
|
client.emit(
|
|
43
47
|
Events.Debug,
|
package/src/index.js
CHANGED
|
@@ -180,6 +180,7 @@ exports.PartialGroupDMChannel = require('./structures/PartialGroupDMChannel');
|
|
|
180
180
|
exports.PermissionOverwrites = require('./structures/PermissionOverwrites');
|
|
181
181
|
exports.Poll = require('./structures/Poll').Poll;
|
|
182
182
|
exports.PollAnswer = require('./structures/PollAnswer').PollAnswer;
|
|
183
|
+
exports.PrimaryEntryPointCommandInteraction = require('./structures/PrimaryEntryPointCommandInteraction');
|
|
183
184
|
exports.Presence = require('./structures/Presence').Presence;
|
|
184
185
|
exports.ReactionCollector = require('./structures/ReactionCollector');
|
|
185
186
|
exports.ReactionEmoji = require('./structures/ReactionEmoji');
|
|
@@ -261,6 +261,7 @@ class ApplicationCommandManager extends CachedManager {
|
|
|
261
261
|
dm_permission: command.dmPermission ?? command.dm_permission,
|
|
262
262
|
integration_types: command.integrationTypes ?? command.integration_types,
|
|
263
263
|
contexts: command.contexts,
|
|
264
|
+
handler: command.handler,
|
|
264
265
|
};
|
|
265
266
|
}
|
|
266
267
|
}
|
|
@@ -69,6 +69,13 @@ class ChannelManager extends CachedManager {
|
|
|
69
69
|
|
|
70
70
|
channel?.parent?.threads?.cache.delete(id);
|
|
71
71
|
this.cache.delete(id);
|
|
72
|
+
|
|
73
|
+
if (channel?.threads) {
|
|
74
|
+
for (const threadId of channel.threads.cache.keys()) {
|
|
75
|
+
this.cache.delete(threadId);
|
|
76
|
+
channel.guild?.channels.cache.delete(threadId);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
/**
|
|
@@ -174,6 +174,18 @@ class ApplicationCommand extends Base {
|
|
|
174
174
|
this.contexts ??= null;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
if ('handler' in data) {
|
|
178
|
+
/**
|
|
179
|
+
* Determines whether the interaction is handled by the app's interactions handler or by Discord.
|
|
180
|
+
* <info>Only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands on
|
|
181
|
+
* applications with the {@link ApplicationFlags.Embedded} flag (i.e, those that have an Activity)</info>
|
|
182
|
+
* @type {?EntryPointCommandHandlerType}
|
|
183
|
+
*/
|
|
184
|
+
this.handler = data.handler;
|
|
185
|
+
} else {
|
|
186
|
+
this.handler ??= null;
|
|
187
|
+
}
|
|
188
|
+
|
|
177
189
|
if ('version' in data) {
|
|
178
190
|
/**
|
|
179
191
|
* Autoincrementing version identifier updated during substantial record changes
|
|
@@ -216,15 +228,20 @@ class ApplicationCommand extends Base {
|
|
|
216
228
|
* @property {string} name The name of the command, must be in all lowercase if type is
|
|
217
229
|
* {@link ApplicationCommandType.ChatInput}
|
|
218
230
|
* @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
|
|
219
|
-
* @property {string} description The description of the command,
|
|
231
|
+
* @property {string} description The description of the command,
|
|
232
|
+
* if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}
|
|
220
233
|
* @property {boolean} [nsfw] Whether the command is age-restricted
|
|
221
234
|
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,
|
|
222
|
-
* if type is {@link ApplicationCommandType.ChatInput}
|
|
235
|
+
* if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}
|
|
223
236
|
* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
|
|
224
237
|
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
|
225
238
|
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
|
226
239
|
* a member needs in order to run the command
|
|
227
240
|
* @property {boolean} [dmPermission] Whether the command is enabled in DMs
|
|
241
|
+
* @property {ApplicationIntegrationType[]} [integrationTypes] Installation contexts where the command is available
|
|
242
|
+
* @property {InteractionContextType[]} [contexts] Interaction contexts where the command can be used
|
|
243
|
+
* @property {EntryPointCommandHandlerType} [handler] Whether the interaction is handled by the app's
|
|
244
|
+
* interactions handler or by Discord.
|
|
228
245
|
*/
|
|
229
246
|
|
|
230
247
|
/**
|
|
@@ -419,7 +436,8 @@ class ApplicationCommand extends Base {
|
|
|
419
436
|
this.descriptionLocalizations ?? {},
|
|
420
437
|
) ||
|
|
421
438
|
!isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) ||
|
|
422
|
-
!isEqual(command.contexts ?? [], this.contexts ?? [])
|
|
439
|
+
!isEqual(command.contexts ?? [], this.contexts ?? []) ||
|
|
440
|
+
('handler' in command && command.handler !== this.handler)
|
|
423
441
|
) {
|
|
424
442
|
return false;
|
|
425
443
|
}
|
|
@@ -122,6 +122,12 @@ class BaseInteraction extends Base {
|
|
|
122
122
|
* @type {?InteractionContextType}
|
|
123
123
|
*/
|
|
124
124
|
this.context = data.context ?? null;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Attachment size limit in bytes
|
|
128
|
+
* @type {number}
|
|
129
|
+
*/
|
|
130
|
+
this.attachmentSizeLimit = data.attachment_size_limit;
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
/**
|
|
@@ -219,6 +225,16 @@ class BaseInteraction extends Base {
|
|
|
219
225
|
);
|
|
220
226
|
}
|
|
221
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Indicates whether this interaction is a {@link PrimaryEntryPointCommandInteraction}
|
|
230
|
+
* @returns {boolean}
|
|
231
|
+
*/
|
|
232
|
+
isPrimaryEntryPointCommand() {
|
|
233
|
+
return (
|
|
234
|
+
this.type === InteractionType.ApplicationCommand && this.commandType === ApplicationCommandType.PrimaryEntryPoint
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
222
238
|
/**
|
|
223
239
|
* Indicates whether this interaction is a {@link MessageComponentInteraction}
|
|
224
240
|
* @returns {boolean}
|
|
@@ -27,7 +27,7 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
27
27
|
* The hash of the channel icon
|
|
28
28
|
* @type {?string}
|
|
29
29
|
*/
|
|
30
|
-
this.icon = data.icon;
|
|
30
|
+
this.icon = data.icon ?? null;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Recipient data received in a {@link PartialGroupDMChannel}.
|
|
@@ -39,7 +39,7 @@ class PartialGroupDMChannel extends BaseChannel {
|
|
|
39
39
|
* The recipients of this Group DM Channel.
|
|
40
40
|
* @type {PartialRecipient[]}
|
|
41
41
|
*/
|
|
42
|
-
this.recipients = data.recipients;
|
|
42
|
+
this.recipients = data.recipients ?? [];
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* A manager of the messages belonging to this channel
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CommandInteraction = require('./CommandInteraction.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a primary entry point command interaction.
|
|
7
|
+
* @extends {CommandInteraction}
|
|
8
|
+
*/
|
|
9
|
+
class PrimaryEntryPointCommandInteraction extends CommandInteraction {}
|
|
10
|
+
|
|
11
|
+
module.exports = PrimaryEntryPointCommandInteraction;
|
|
@@ -69,6 +69,12 @@ class InteractionResponses {
|
|
|
69
69
|
* <warn>This option is deprecated. Use `withResponse` or fetch the response instead.</warn>
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Options for launching activity in response to a {@link BaseInteraction}
|
|
74
|
+
* @typedef {Object} LaunchActivityOptions
|
|
75
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
76
|
+
*/
|
|
77
|
+
|
|
72
78
|
/**
|
|
73
79
|
* Options for showing a modal in response to a {@link BaseInteraction}
|
|
74
80
|
* @typedef {Object} ShowModalOptions
|
|
@@ -370,6 +376,25 @@ class InteractionResponses {
|
|
|
370
376
|
: new InteractionResponse(this, this.message.interactionMetadata?.id);
|
|
371
377
|
}
|
|
372
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Launches this application's activity, if enabled
|
|
381
|
+
* @param {LaunchActivityOptions} [options={}] Options for launching the activity
|
|
382
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
383
|
+
*/
|
|
384
|
+
async launchActivity({ withResponse } = {}) {
|
|
385
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
386
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
387
|
+
query: makeURLSearchParams({ with_response: withResponse ?? false }),
|
|
388
|
+
body: {
|
|
389
|
+
type: InteractionResponseType.LaunchActivity,
|
|
390
|
+
},
|
|
391
|
+
auth: false,
|
|
392
|
+
});
|
|
393
|
+
this.replied = true;
|
|
394
|
+
|
|
395
|
+
return withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
396
|
+
}
|
|
397
|
+
|
|
373
398
|
/**
|
|
374
399
|
* Shows a modal component
|
|
375
400
|
* @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show
|
|
@@ -450,6 +475,7 @@ class InteractionResponses {
|
|
|
450
475
|
'followUp',
|
|
451
476
|
'deferUpdate',
|
|
452
477
|
'update',
|
|
478
|
+
'launchActivity',
|
|
453
479
|
'showModal',
|
|
454
480
|
'sendPremiumRequired',
|
|
455
481
|
'awaitModalSubmit',
|
package/src/util/APITypes.js
CHANGED
|
@@ -370,6 +370,11 @@
|
|
|
370
370
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntitlementType}
|
|
371
371
|
*/
|
|
372
372
|
|
|
373
|
+
/**
|
|
374
|
+
* @external EntryPointCommandHandlerType
|
|
375
|
+
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntryPointCommandHandlerType}
|
|
376
|
+
*/
|
|
377
|
+
|
|
373
378
|
/**
|
|
374
379
|
* @external ForumLayoutType
|
|
375
380
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ForumLayoutType}
|
package/src/util/Components.js
CHANGED
|
@@ -141,44 +141,7 @@ const { ComponentType } = require('discord-api-types/v10');
|
|
|
141
141
|
* @ignore
|
|
142
142
|
*/
|
|
143
143
|
function createComponent(data) {
|
|
144
|
-
|
|
145
|
-
return data;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
switch (data.type) {
|
|
149
|
-
case ComponentType.ActionRow:
|
|
150
|
-
return new ActionRow(data);
|
|
151
|
-
case ComponentType.Button:
|
|
152
|
-
return new ButtonComponent(data);
|
|
153
|
-
case ComponentType.StringSelect:
|
|
154
|
-
return new StringSelectMenuComponent(data);
|
|
155
|
-
case ComponentType.TextInput:
|
|
156
|
-
return new TextInputComponent(data);
|
|
157
|
-
case ComponentType.UserSelect:
|
|
158
|
-
return new UserSelectMenuComponent(data);
|
|
159
|
-
case ComponentType.RoleSelect:
|
|
160
|
-
return new RoleSelectMenuComponent(data);
|
|
161
|
-
case ComponentType.MentionableSelect:
|
|
162
|
-
return new MentionableSelectMenuComponent(data);
|
|
163
|
-
case ComponentType.ChannelSelect:
|
|
164
|
-
return new ChannelSelectMenuComponent(data);
|
|
165
|
-
case ComponentType.Container:
|
|
166
|
-
return new ContainerComponent(data);
|
|
167
|
-
case ComponentType.TextDisplay:
|
|
168
|
-
return new TextDisplayComponent(data);
|
|
169
|
-
case ComponentType.File:
|
|
170
|
-
return new FileComponent(data);
|
|
171
|
-
case ComponentType.MediaGallery:
|
|
172
|
-
return new MediaGalleryComponent(data);
|
|
173
|
-
case ComponentType.Section:
|
|
174
|
-
return new SectionComponent(data);
|
|
175
|
-
case ComponentType.Separator:
|
|
176
|
-
return new SeparatorComponent(data);
|
|
177
|
-
case ComponentType.Thumbnail:
|
|
178
|
-
return new ThumbnailComponent(data);
|
|
179
|
-
default:
|
|
180
|
-
return new Component(data);
|
|
181
|
-
}
|
|
144
|
+
return data instanceof Component ? data : new (ComponentTypeToComponent[data.type] ?? Component)(data);
|
|
182
145
|
}
|
|
183
146
|
|
|
184
147
|
/**
|
|
@@ -188,30 +151,7 @@ function createComponent(data) {
|
|
|
188
151
|
* @ignore
|
|
189
152
|
*/
|
|
190
153
|
function createComponentBuilder(data) {
|
|
191
|
-
|
|
192
|
-
return data;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
switch (data.type) {
|
|
196
|
-
case ComponentType.ActionRow:
|
|
197
|
-
return new ActionRowBuilder(data);
|
|
198
|
-
case ComponentType.Button:
|
|
199
|
-
return new ButtonBuilder(data);
|
|
200
|
-
case ComponentType.StringSelect:
|
|
201
|
-
return new StringSelectMenuBuilder(data);
|
|
202
|
-
case ComponentType.TextInput:
|
|
203
|
-
return new TextInputBuilder(data);
|
|
204
|
-
case ComponentType.UserSelect:
|
|
205
|
-
return new UserSelectMenuBuilder(data);
|
|
206
|
-
case ComponentType.RoleSelect:
|
|
207
|
-
return new RoleSelectMenuBuilder(data);
|
|
208
|
-
case ComponentType.MentionableSelect:
|
|
209
|
-
return new MentionableSelectMenuBuilder(data);
|
|
210
|
-
case ComponentType.ChannelSelect:
|
|
211
|
-
return new ChannelSelectMenuBuilder(data);
|
|
212
|
-
default:
|
|
213
|
-
return new ComponentBuilder(data);
|
|
214
|
-
}
|
|
154
|
+
return data instanceof ComponentBuilder ? data : new (ComponentTypeToBuilder[data.type] ?? ComponentBuilder)(data);
|
|
215
155
|
}
|
|
216
156
|
|
|
217
157
|
/**
|
|
@@ -274,3 +214,32 @@ const TextInputComponent = require('../structures/TextInputComponent');
|
|
|
274
214
|
const ThumbnailComponent = require('../structures/ThumbnailComponent');
|
|
275
215
|
const UserSelectMenuBuilder = require('../structures/UserSelectMenuBuilder');
|
|
276
216
|
const UserSelectMenuComponent = require('../structures/UserSelectMenuComponent');
|
|
217
|
+
|
|
218
|
+
const ComponentTypeToComponent = {
|
|
219
|
+
[ComponentType.ActionRow]: ActionRow,
|
|
220
|
+
[ComponentType.Button]: ButtonComponent,
|
|
221
|
+
[ComponentType.StringSelect]: StringSelectMenuComponent,
|
|
222
|
+
[ComponentType.TextInput]: TextInputComponent,
|
|
223
|
+
[ComponentType.UserSelect]: UserSelectMenuComponent,
|
|
224
|
+
[ComponentType.RoleSelect]: RoleSelectMenuComponent,
|
|
225
|
+
[ComponentType.MentionableSelect]: MentionableSelectMenuComponent,
|
|
226
|
+
[ComponentType.ChannelSelect]: ChannelSelectMenuComponent,
|
|
227
|
+
[ComponentType.Container]: ContainerComponent,
|
|
228
|
+
[ComponentType.TextDisplay]: TextDisplayComponent,
|
|
229
|
+
[ComponentType.File]: FileComponent,
|
|
230
|
+
[ComponentType.MediaGallery]: MediaGalleryComponent,
|
|
231
|
+
[ComponentType.Section]: SectionComponent,
|
|
232
|
+
[ComponentType.Separator]: SeparatorComponent,
|
|
233
|
+
[ComponentType.Thumbnail]: ThumbnailComponent,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const ComponentTypeToBuilder = {
|
|
237
|
+
[ComponentType.ActionRow]: ActionRowBuilder,
|
|
238
|
+
[ComponentType.Button]: ButtonBuilder,
|
|
239
|
+
[ComponentType.StringSelect]: StringSelectMenuBuilder,
|
|
240
|
+
[ComponentType.TextInput]: TextInputBuilder,
|
|
241
|
+
[ComponentType.UserSelect]: UserSelectMenuBuilder,
|
|
242
|
+
[ComponentType.RoleSelect]: RoleSelectMenuBuilder,
|
|
243
|
+
[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder,
|
|
244
|
+
[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder,
|
|
245
|
+
};
|
package/src/util/Transformers.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { isJSONEncodable } = require('@discordjs/util');
|
|
4
4
|
const snakeCase = require('lodash.snakecase');
|
|
5
|
+
const { resolvePartialEmoji } = require('./Util');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Transforms camel-cased keys into snake cased keys
|
|
@@ -13,7 +14,14 @@ function toSnakeCase(obj) {
|
|
|
13
14
|
if (obj instanceof Date) return obj;
|
|
14
15
|
if (isJSONEncodable(obj)) return toSnakeCase(obj.toJSON());
|
|
15
16
|
if (Array.isArray(obj)) return obj.map(toSnakeCase);
|
|
16
|
-
return Object.fromEntries(
|
|
17
|
+
return Object.fromEntries(
|
|
18
|
+
Object.entries(obj).map(([key, value]) => [
|
|
19
|
+
snakeCase(key),
|
|
20
|
+
// TODO: The special handling of 'emoji' is just a temporary fix for v14, will be dropped in v15.
|
|
21
|
+
// See https://github.com/discordjs/discord.js/issues/10909
|
|
22
|
+
key === 'emoji' && typeof value === 'string' ? resolvePartialEmoji(value) : toSnakeCase(value),
|
|
23
|
+
]),
|
|
24
|
+
);
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
/**
|
package/typings/index.d.mts
CHANGED
|
@@ -213,6 +213,7 @@ import {
|
|
|
213
213
|
SeparatorSpacingSize,
|
|
214
214
|
APIFileComponent,
|
|
215
215
|
APIMessageTopLevelComponent,
|
|
216
|
+
EntryPointCommandHandlerType,
|
|
216
217
|
} from 'discord-api-types/v10';
|
|
217
218
|
import { ChildProcess } from 'node:child_process';
|
|
218
219
|
import { EventEmitter } from 'node:events';
|
|
@@ -480,6 +481,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
|
|
480
481
|
public get manager(): ApplicationCommandManager;
|
|
481
482
|
public id: Snowflake;
|
|
482
483
|
public integrationTypes: ApplicationIntegrationType[] | null;
|
|
484
|
+
public handler: EntryPointCommandHandlerType | null;
|
|
483
485
|
public name: string;
|
|
484
486
|
public nameLocalizations: LocalizationMap | null;
|
|
485
487
|
public nameLocalized: string | null;
|
|
@@ -583,23 +585,6 @@ export type BooleanCache<Cached extends CacheType> = Cached extends 'cached' ? t
|
|
|
583
585
|
export abstract class CommandInteraction<Cached extends CacheType = CacheType> extends BaseInteraction<Cached> {
|
|
584
586
|
public type: InteractionType.ApplicationCommand;
|
|
585
587
|
public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
|
|
586
|
-
public options: Omit<
|
|
587
|
-
CommandInteractionOptionResolver<Cached>,
|
|
588
|
-
| 'getMessage'
|
|
589
|
-
| 'getFocused'
|
|
590
|
-
| 'getMentionable'
|
|
591
|
-
| 'getRole'
|
|
592
|
-
| 'getUser'
|
|
593
|
-
| 'getMember'
|
|
594
|
-
| 'getAttachment'
|
|
595
|
-
| 'getNumber'
|
|
596
|
-
| 'getInteger'
|
|
597
|
-
| 'getString'
|
|
598
|
-
| 'getChannel'
|
|
599
|
-
| 'getBoolean'
|
|
600
|
-
| 'getSubcommandGroup'
|
|
601
|
-
| 'getSubcommand'
|
|
602
|
-
>;
|
|
603
588
|
public channelId: Snowflake;
|
|
604
589
|
public commandId: Snowflake;
|
|
605
590
|
public commandName: string;
|
|
@@ -632,6 +617,9 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
|
|
|
632
617
|
public reply(
|
|
633
618
|
options: string | MessagePayload | InteractionReplyOptions,
|
|
634
619
|
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
|
620
|
+
public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
|
621
|
+
public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise<undefined>;
|
|
622
|
+
public launchActivity(options?: LaunchActivityOptions): Promise<InteractionCallbackResponse | undefined>;
|
|
635
623
|
public showModal(
|
|
636
624
|
modal:
|
|
637
625
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
|
@@ -1439,6 +1427,23 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
|
|
|
1439
1427
|
}
|
|
1440
1428
|
|
|
1441
1429
|
export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> {
|
|
1430
|
+
public options: Omit<
|
|
1431
|
+
CommandInteractionOptionResolver<Cached>,
|
|
1432
|
+
| 'getMessage'
|
|
1433
|
+
| 'getFocused'
|
|
1434
|
+
| 'getMentionable'
|
|
1435
|
+
| 'getRole'
|
|
1436
|
+
| 'getUser'
|
|
1437
|
+
| 'getMember'
|
|
1438
|
+
| 'getAttachment'
|
|
1439
|
+
| 'getNumber'
|
|
1440
|
+
| 'getInteger'
|
|
1441
|
+
| 'getString'
|
|
1442
|
+
| 'getChannel'
|
|
1443
|
+
| 'getBoolean'
|
|
1444
|
+
| 'getSubcommandGroup'
|
|
1445
|
+
| 'getSubcommand'
|
|
1446
|
+
>;
|
|
1442
1447
|
public commandType: ApplicationCommandType.Message | ApplicationCommandType.User;
|
|
1443
1448
|
public targetId: Snowflake;
|
|
1444
1449
|
public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>;
|
|
@@ -1447,6 +1452,15 @@ export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType>
|
|
|
1447
1452
|
private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption<Cached>[];
|
|
1448
1453
|
}
|
|
1449
1454
|
|
|
1455
|
+
export class PrimaryEntryPointCommandInteraction<
|
|
1456
|
+
Cached extends CacheType = CacheType,
|
|
1457
|
+
> extends CommandInteraction<Cached> {
|
|
1458
|
+
public commandType: ApplicationCommandType.PrimaryEntryPoint;
|
|
1459
|
+
public inGuild(): this is PrimaryEntryPointCommandInteraction<'raw' | 'cached'>;
|
|
1460
|
+
public inCachedGuild(): this is PrimaryEntryPointCommandInteraction<'cached'>;
|
|
1461
|
+
public inRawGuild(): this is PrimaryEntryPointCommandInteraction<'raw'>;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1450
1464
|
// tslint:disable-next-line no-empty-interface
|
|
1451
1465
|
export interface DMChannel
|
|
1452
1466
|
extends Omit<
|
|
@@ -2062,6 +2076,7 @@ export type Interaction<Cached extends CacheType = CacheType> =
|
|
|
2062
2076
|
| ChatInputCommandInteraction<Cached>
|
|
2063
2077
|
| MessageContextMenuCommandInteraction<Cached>
|
|
2064
2078
|
| UserContextMenuCommandInteraction<Cached>
|
|
2079
|
+
| PrimaryEntryPointCommandInteraction<Cached>
|
|
2065
2080
|
| AnySelectMenuInteraction<Cached>
|
|
2066
2081
|
| ButtonInteraction<Cached>
|
|
2067
2082
|
| AutocompleteInteraction<Cached>
|
|
@@ -2102,6 +2117,7 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
|
|
|
2102
2117
|
public locale: Locale;
|
|
2103
2118
|
public guildLocale: CacheTypeReducer<Cached, Locale>;
|
|
2104
2119
|
public entitlements: Collection<Snowflake, Entitlement>;
|
|
2120
|
+
public attachmentSizeLimit: number;
|
|
2105
2121
|
public inGuild(): this is BaseInteraction<'raw' | 'cached'>;
|
|
2106
2122
|
public inCachedGuild(): this is BaseInteraction<'cached'>;
|
|
2107
2123
|
public inRawGuild(): this is BaseInteraction<'raw'>;
|
|
@@ -2110,6 +2126,7 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
|
|
|
2110
2126
|
public isChatInputCommand(): this is ChatInputCommandInteraction<Cached>;
|
|
2111
2127
|
public isCommand(): this is CommandInteraction<Cached>;
|
|
2112
2128
|
public isContextMenuCommand(): this is ContextMenuCommandInteraction<Cached>;
|
|
2129
|
+
public isPrimaryEntryPointCommand(): this is PrimaryEntryPointCommandInteraction<Cached>;
|
|
2113
2130
|
public isMessageComponent(): this is MessageComponentInteraction<Cached>;
|
|
2114
2131
|
public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction<Cached>;
|
|
2115
2132
|
public isModalSubmit(): this is ModalSubmitInteraction<Cached>;
|
|
@@ -2537,6 +2554,9 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|
|
2537
2554
|
public update(
|
|
2538
2555
|
options: string | MessagePayload | InteractionUpdateOptions,
|
|
2539
2556
|
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
|
2557
|
+
public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
|
2558
|
+
public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise<undefined>;
|
|
2559
|
+
public launchActivity(options?: LaunchActivityOptions): Promise<InteractionCallbackResponse | undefined>;
|
|
2540
2560
|
public showModal(
|
|
2541
2561
|
modal:
|
|
2542
2562
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
|
@@ -2783,6 +2803,9 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
|
|
|
2783
2803
|
public deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
|
2784
2804
|
/** @deprecated Sending a premium-style button is the new Discord behaviour. */
|
|
2785
2805
|
public sendPremiumRequired(): Promise<void>;
|
|
2806
|
+
public launchActivity(options: LaunchActivityOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
|
2807
|
+
public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise<undefined>;
|
|
2808
|
+
public launchActivity(options?: LaunchActivityOptions): Promise<InteractionCallbackResponse | undefined>;
|
|
2786
2809
|
public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>;
|
|
2787
2810
|
public inCachedGuild(): this is ModalSubmitInteraction<'cached'>;
|
|
2788
2811
|
public inRawGuild(): this is ModalSubmitInteraction<'raw'>;
|
|
@@ -5270,10 +5293,18 @@ export interface ChatInputApplicationCommandData extends BaseApplicationCommandD
|
|
|
5270
5293
|
options?: readonly ApplicationCommandOptionData[];
|
|
5271
5294
|
}
|
|
5272
5295
|
|
|
5296
|
+
export interface PrimaryEntryPointCommandData extends BaseApplicationCommandData {
|
|
5297
|
+
description?: string;
|
|
5298
|
+
descriptionLocalizations?: LocalizationMap;
|
|
5299
|
+
type: ApplicationCommandType.PrimaryEntryPoint;
|
|
5300
|
+
handler?: EntryPointCommandHandlerType;
|
|
5301
|
+
}
|
|
5302
|
+
|
|
5273
5303
|
export type ApplicationCommandData =
|
|
5274
5304
|
| UserApplicationCommandData
|
|
5275
5305
|
| MessageApplicationCommandData
|
|
5276
|
-
| ChatInputApplicationCommandData
|
|
5306
|
+
| ChatInputApplicationCommandData
|
|
5307
|
+
| PrimaryEntryPointCommandData;
|
|
5277
5308
|
|
|
5278
5309
|
export interface ApplicationCommandChannelOptionData extends BaseApplicationCommandOptionsData {
|
|
5279
5310
|
type: CommandOptionChannelResolvableType;
|
|
@@ -7375,6 +7406,10 @@ export interface ShowModalOptions {
|
|
|
7375
7406
|
withResponse?: boolean;
|
|
7376
7407
|
}
|
|
7377
7408
|
|
|
7409
|
+
export interface LaunchActivityOptions {
|
|
7410
|
+
withResponse?: boolean;
|
|
7411
|
+
}
|
|
7412
|
+
|
|
7378
7413
|
export { Snowflake };
|
|
7379
7414
|
|
|
7380
7415
|
export type StageInstanceResolvable = StageInstance | Snowflake;
|