seyfert 2.1.0 → 2.1.1-dev-11316886063.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/lib/api/Router.d.ts +2 -2
- package/lib/api/Router.js +2 -1
- package/lib/api/Routes/applications.d.ts +29 -30
- package/lib/api/Routes/cdn.d.ts +6 -1
- package/lib/api/Routes/channels.d.ts +44 -45
- package/lib/api/Routes/gateway.d.ts +3 -4
- package/lib/api/Routes/guilds.d.ts +81 -80
- package/lib/api/Routes/index.d.ts +3 -1
- package/lib/api/Routes/interactions.d.ts +6 -6
- package/lib/api/Routes/invites.d.ts +3 -4
- package/lib/api/Routes/skus.d.ts +4 -5
- package/lib/api/Routes/soundboard.d.ts +23 -0
- package/lib/api/Routes/soundboard.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +5 -6
- package/lib/api/Routes/stickers.d.ts +3 -4
- package/lib/api/Routes/users.d.ts +11 -12
- package/lib/api/Routes/voice.d.ts +2 -3
- package/lib/api/Routes/webhooks.d.ts +16 -15
- package/lib/api/api.d.ts +17 -11
- package/lib/api/api.js +12 -10
- package/lib/api/shared.d.ts +1 -1
- package/lib/api/utils/constants.d.ts +2 -0
- package/lib/api/utils/constants.js +2 -1
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/Attachment.d.ts +2 -2
- package/lib/builders/Attachment.js +1 -1
- package/lib/builders/Button.d.ts +1 -1
- package/lib/builders/Button.js +1 -1
- package/lib/builders/Embed.d.ts +1 -1
- package/lib/builders/Embed.js +2 -2
- package/lib/builders/Modal.d.ts +1 -1
- package/lib/builders/Poll.d.ts +1 -1
- package/lib/builders/Poll.js +1 -1
- package/lib/builders/SelectMenu.d.ts +1 -1
- package/lib/builders/SelectMenu.js +1 -1
- package/lib/builders/types.d.ts +2 -1
- package/lib/cache/adapters/default.js +5 -3
- package/lib/cache/adapters/limited.d.ts +1 -2
- package/lib/cache/adapters/limited.js +34 -30
- package/lib/cache/adapters/workeradapter.js +3 -1
- package/lib/cache/index.d.ts +8 -11
- package/lib/cache/index.js +38 -37
- package/lib/cache/resources/bans.d.ts +2 -2
- package/lib/cache/resources/bans.js +1 -1
- package/lib/cache/resources/channels.d.ts +1 -1
- package/lib/cache/resources/default/guild-related.d.ts +1 -2
- package/lib/cache/resources/emojis.d.ts +2 -2
- package/lib/cache/resources/emojis.js +1 -1
- package/lib/cache/resources/guilds.d.ts +2 -2
- package/lib/cache/resources/guilds.js +7 -11
- package/lib/cache/resources/members.d.ts +2 -2
- package/lib/cache/resources/members.js +1 -1
- package/lib/cache/resources/messages.d.ts +2 -2
- package/lib/cache/resources/messages.js +3 -3
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/roles.d.ts +2 -2
- package/lib/cache/resources/roles.js +1 -1
- package/lib/cache/resources/stickers.d.ts +2 -2
- package/lib/cache/resources/stickers.js +1 -1
- package/lib/cache/resources/users.d.ts +2 -2
- package/lib/cache/resources/users.js +1 -1
- package/lib/cache/resources/voice-states.d.ts +2 -2
- package/lib/cache/resources/voice-states.js +1 -1
- package/lib/client/base.d.ts +9 -14
- package/lib/client/base.js +43 -44
- package/lib/client/client.d.ts +3 -7
- package/lib/client/client.js +24 -41
- package/lib/client/collectors.js +1 -1
- package/lib/client/httpclient.d.ts +1 -1
- package/lib/client/transformers.d.ts +37 -34
- package/lib/client/transformers.js +66 -63
- package/lib/client/workerclient.d.ts +10 -11
- package/lib/client/workerclient.js +180 -75
- package/lib/collection.d.ts +3 -3
- package/lib/commands/applications/chat.d.ts +12 -32
- package/lib/commands/applications/chat.js +5 -6
- package/lib/commands/applications/chatcontext.d.ts +6 -6
- package/lib/commands/applications/chatcontext.js +16 -8
- package/lib/commands/applications/entryPoint.d.ts +1 -1
- package/lib/commands/applications/entrycontext.d.ts +6 -6
- package/lib/commands/applications/entrycontext.js +4 -4
- package/lib/commands/applications/menu.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +5 -5
- package/lib/commands/applications/menucontext.js +6 -6
- package/lib/commands/applications/options.d.ts +104 -28
- package/lib/commands/applications/options.js +4 -4
- package/lib/commands/applications/shared.d.ts +5 -2
- package/lib/commands/basecontext.d.ts +1 -1
- package/lib/commands/decorators.d.ts +10 -10
- package/lib/commands/decorators.js +5 -4
- package/lib/commands/handle.d.ts +9 -9
- package/lib/commands/handle.js +94 -68
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +21 -17
- package/lib/commands/optionresolver.d.ts +4 -4
- package/lib/commands/optionresolver.js +3 -3
- package/lib/common/it/formatter.d.ts +21 -21
- package/lib/common/it/formatter.js +40 -41
- package/lib/common/it/logger.js +1 -1
- package/lib/common/it/utils.d.ts +4 -3
- package/lib/common/it/utils.js +52 -27
- package/lib/common/shorters/application.d.ts +2 -3
- package/lib/common/shorters/application.js +3 -3
- package/lib/common/shorters/bans.js +1 -1
- package/lib/common/shorters/channels.d.ts +3 -3
- package/lib/common/shorters/channels.js +3 -3
- package/lib/common/shorters/emojis.js +4 -4
- package/lib/common/shorters/guilds.d.ts +3 -3
- package/lib/common/shorters/guilds.js +5 -9
- package/lib/common/shorters/interaction.d.ts +3 -3
- package/lib/common/shorters/interaction.js +6 -5
- package/lib/common/shorters/members.d.ts +4 -5
- package/lib/common/shorters/members.js +6 -7
- package/lib/common/shorters/messages.d.ts +1 -1
- package/lib/common/shorters/messages.js +4 -4
- package/lib/common/shorters/reactions.d.ts +1 -1
- package/lib/common/shorters/reactions.js +1 -1
- package/lib/common/shorters/roles.js +1 -1
- package/lib/common/shorters/templates.js +2 -2
- package/lib/common/shorters/threads.d.ts +1 -1
- package/lib/common/shorters/threads.js +17 -11
- package/lib/common/shorters/webhook.d.ts +1 -1
- package/lib/common/shorters/webhook.js +4 -4
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/resolvables.d.ts +1 -1
- package/lib/common/types/util.d.ts +4 -1
- package/lib/common/types/write.d.ts +1 -1
- package/lib/components/BaseComponent.js +1 -1
- package/lib/components/ButtonComponent.d.ts +1 -1
- package/lib/components/componentcommand.d.ts +1 -1
- package/lib/components/componentcontext.d.ts +4 -4
- package/lib/components/componentcontext.js +1 -1
- package/lib/components/handler.d.ts +10 -8
- package/lib/components/handler.js +16 -13
- package/lib/components/index.js +2 -1
- package/lib/components/modalcontext.d.ts +2 -2
- package/lib/components/modalcontext.js +1 -1
- package/lib/deps/mixer.d.ts +1 -1
- package/lib/events/handler.d.ts +5 -5
- package/lib/events/handler.js +66 -16
- package/lib/events/hooks/application_command.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.js +1 -1
- package/lib/events/hooks/channel.d.ts +1 -1
- package/lib/events/hooks/dispatch.d.ts +1 -1
- package/lib/events/hooks/entitlement.d.ts +4 -5
- package/lib/events/hooks/entitlement.js +4 -4
- package/lib/events/hooks/guild.d.ts +3 -3
- package/lib/events/hooks/guild.js +1 -1
- package/lib/events/hooks/index.d.ts +1 -0
- package/lib/events/hooks/index.js +1 -0
- package/lib/events/hooks/integration.d.ts +1 -1
- package/lib/events/hooks/integration.js +1 -1
- package/lib/events/hooks/interactions.d.ts +3 -3
- package/lib/events/hooks/invite.d.ts +1 -1
- package/lib/events/hooks/message.d.ts +3 -3
- package/lib/events/hooks/message.js +1 -1
- package/lib/events/hooks/presence.d.ts +2 -2
- package/lib/events/hooks/soundboard.d.ts +155 -0
- package/lib/events/hooks/soundboard.js +28 -0
- package/lib/events/hooks/stage.d.ts +2 -2
- package/lib/events/hooks/thread.d.ts +2 -2
- package/lib/events/hooks/thread.js +2 -2
- package/lib/events/hooks/typing.d.ts +1 -1
- package/lib/events/hooks/typing.js +1 -1
- package/lib/events/hooks/user.d.ts +2 -2
- package/lib/events/hooks/voice.d.ts +2 -2
- package/lib/events/hooks/voice.js +1 -1
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -5
- package/lib/langs/handler.d.ts +2 -2
- package/lib/structures/Guild.d.ts +7 -4
- package/lib/structures/Guild.js +1 -1
- package/lib/structures/GuildBan.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -5
- package/lib/structures/GuildMember.js +5 -3
- package/lib/structures/GuildRole.d.ts +1 -1
- package/lib/structures/GuildTemplate.d.ts +1 -1
- package/lib/structures/Interaction.d.ts +17 -14
- package/lib/structures/Interaction.js +28 -21
- package/lib/structures/Message.d.ts +4 -7
- package/lib/structures/Message.js +5 -5
- package/lib/structures/Poll.d.ts +3 -3
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/VoiceState.d.ts +2 -1
- package/lib/structures/VoiceState.js +1 -1
- package/lib/structures/Webhook.d.ts +3 -3
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +4 -4
- package/lib/structures/channels.js +6 -5
- package/lib/structures/extra/BitField.d.ts +3 -3
- package/lib/structures/extra/BitField.js +34 -33
- package/lib/structures/extra/DiscordBase.js +1 -1
- package/lib/structures/extra/Permissions.d.ts +2 -0
- package/lib/structures/extra/Permissions.js +21 -0
- package/lib/types/gateway.d.ts +53 -5
- package/lib/types/payloads/_interactions/base.d.ts +1 -1
- package/lib/types/payloads/channel.d.ts +2 -2
- package/lib/types/payloads/guild.d.ts +9 -1
- package/lib/types/payloads/guild.js +8 -0
- package/lib/types/payloads/index.d.ts +1 -0
- package/lib/types/payloads/index.js +1 -0
- package/lib/types/payloads/soundboard.d.ts +23 -0
- package/lib/types/payloads/soundboard.js +5 -0
- package/lib/types/payloads/user.js +0 -1
- package/lib/types/rest/application.d.ts +3 -3
- package/lib/types/rest/auditLog.d.ts +1 -1
- package/lib/types/rest/channel.d.ts +2 -2
- package/lib/types/rest/guild.d.ts +2 -2
- package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
- package/lib/types/rest/index.d.ts +1 -0
- package/lib/types/rest/index.js +1 -0
- package/lib/types/rest/oauth2.d.ts +1 -1
- package/lib/types/rest/poll.d.ts +1 -1
- package/lib/types/rest/soundboard.d.ts +64 -0
- package/lib/types/rest/soundboard.js +2 -0
- package/lib/types/rest/stageInstance.d.ts +1 -1
- package/lib/types/rest/template.d.ts +1 -1
- package/lib/types/rest/user.d.ts +1 -1
- package/lib/types/rest/webhook.d.ts +1 -1
- package/lib/types/utils/index.d.ts +11 -2
- package/lib/types/utils/index.js +10 -2
- package/lib/websocket/SharedTypes.d.ts +11 -2
- package/lib/websocket/constants/index.js +0 -10
- package/lib/websocket/discord/basesocket.d.ts +1 -1
- package/lib/websocket/discord/shard.d.ts +1 -1
- package/lib/websocket/discord/shard.js +25 -16
- package/lib/websocket/discord/sharder.d.ts +9 -6
- package/lib/websocket/discord/sharder.js +91 -74
- package/lib/websocket/discord/shared.d.ts +3 -14
- package/lib/websocket/discord/socket/custom.js +19 -6
- package/lib/websocket/discord/worker.d.ts +8 -2
- package/lib/websocket/discord/workermanager.d.ts +42 -17
- package/lib/websocket/discord/workermanager.js +144 -37
- package/lib/websocket/structures/timeout.d.ts +4 -5
- package/lib/websocket/structures/timeout.js +23 -24
- package/package.json +72 -70
- package/lib/cache/resources/threads.d.ts +0 -14
- package/lib/cache/resources/threads.js +0 -32
package/lib/commands/handle.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HandleCommand = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
4
|
const _1 = require(".");
|
|
6
|
-
const structures_1 = require("../structures");
|
|
7
|
-
const components_1 = require("../components");
|
|
8
5
|
const transformers_1 = require("../client/transformers");
|
|
6
|
+
const components_1 = require("../components");
|
|
7
|
+
const structures_1 = require("../structures");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
9
|
class HandleCommand {
|
|
10
10
|
client;
|
|
11
11
|
constructor(client) {
|
|
@@ -40,7 +40,7 @@ class HandleCommand {
|
|
|
40
40
|
return this.contextMenuUser(command, interaction, context);
|
|
41
41
|
}
|
|
42
42
|
async contextMenuUser(command, interaction, context) {
|
|
43
|
-
if (command.botPermissions && interaction.appPermissions) {
|
|
43
|
+
if (context.guildId && command.botPermissions && interaction.appPermissions) {
|
|
44
44
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
|
45
45
|
if (permissions)
|
|
46
46
|
return command.onBotPermissionsFail(context, permissions);
|
|
@@ -71,10 +71,10 @@ class HandleCommand {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
async entryPoint(command, interaction, context) {
|
|
74
|
-
if (command.botPermissions && interaction.appPermissions) {
|
|
74
|
+
if (context.guildId && command.botPermissions && interaction.appPermissions) {
|
|
75
75
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
|
76
76
|
if (permissions)
|
|
77
|
-
return command.onBotPermissionsFail
|
|
77
|
+
return command.onBotPermissionsFail(context, permissions);
|
|
78
78
|
}
|
|
79
79
|
const resultGlobal = await this.runGlobalMiddlewares(command, context);
|
|
80
80
|
if (typeof resultGlobal === 'boolean')
|
|
@@ -102,10 +102,17 @@ class HandleCommand {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
async chatInput(command, interaction, resolver, context) {
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
if (context.guildId && interaction.appPermissions) {
|
|
106
|
+
if (command.botPermissions) {
|
|
107
|
+
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
|
108
|
+
if (permissions)
|
|
109
|
+
return command.onBotPermissionsFail?.(context, permissions);
|
|
110
|
+
}
|
|
111
|
+
if (command.defaultMemberPermissions) {
|
|
112
|
+
const permissions = this.checkPermissions(interaction.member.permissions, command.defaultMemberPermissions);
|
|
113
|
+
if (permissions)
|
|
114
|
+
return command.onPermissionsFail?.(context, permissions);
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
117
|
if (!(await this.runOptions(command, context, resolver)))
|
|
111
118
|
return;
|
|
@@ -164,8 +171,9 @@ class HandleCommand {
|
|
|
164
171
|
const data = this.makeMenuCommand(body, shardId, __reply);
|
|
165
172
|
if (!data)
|
|
166
173
|
return;
|
|
174
|
+
this.contextMenuMessage(data.command,
|
|
167
175
|
// @ts-expect-error
|
|
168
|
-
|
|
176
|
+
data.interaction, data.context);
|
|
169
177
|
break;
|
|
170
178
|
}
|
|
171
179
|
case types_1.ApplicationCommandType.User: {
|
|
@@ -285,7 +293,7 @@ class HandleCommand {
|
|
|
285
293
|
if (command.botPermissions) {
|
|
286
294
|
const appPermissions = await self.members.permissions(rawMessage.guild_id, self.botId);
|
|
287
295
|
const permissions = this.checkPermissions(appPermissions, command.botPermissions);
|
|
288
|
-
if (
|
|
296
|
+
if (permissions) {
|
|
289
297
|
return command.onBotPermissionsFail?.(context, permissions);
|
|
290
298
|
}
|
|
291
299
|
}
|
|
@@ -311,7 +319,9 @@ class HandleCommand {
|
|
|
311
319
|
try {
|
|
312
320
|
await command.onInternalError?.(this.client, command, error);
|
|
313
321
|
}
|
|
314
|
-
catch {
|
|
322
|
+
catch {
|
|
323
|
+
// http 418
|
|
324
|
+
}
|
|
315
325
|
}
|
|
316
326
|
}
|
|
317
327
|
argsParser(content, _command, _message) {
|
|
@@ -387,34 +397,36 @@ class HandleCommand {
|
|
|
387
397
|
});
|
|
388
398
|
}
|
|
389
399
|
checkPermissions(app, bot) {
|
|
400
|
+
if (app.has('Administrator'))
|
|
401
|
+
return;
|
|
390
402
|
const permissions = app.missings(...app.values([bot]));
|
|
391
|
-
if (
|
|
403
|
+
if (permissions.length) {
|
|
392
404
|
return app.keys(permissions);
|
|
393
405
|
}
|
|
394
406
|
return;
|
|
395
407
|
}
|
|
396
|
-
|
|
408
|
+
fetchChannel(_option, query) {
|
|
397
409
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
398
410
|
if (id)
|
|
399
411
|
return this.client.channels.raw(id);
|
|
400
412
|
return null;
|
|
401
413
|
}
|
|
402
|
-
|
|
414
|
+
fetchUser(_option, query) {
|
|
403
415
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
404
416
|
if (id)
|
|
405
417
|
return this.client.users.raw(id);
|
|
406
418
|
return null;
|
|
407
419
|
}
|
|
408
|
-
|
|
420
|
+
fetchMember(_option, query, guildId) {
|
|
409
421
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
410
422
|
if (id)
|
|
411
423
|
return this.client.members.raw(guildId, id);
|
|
412
424
|
return null;
|
|
413
425
|
}
|
|
414
|
-
|
|
426
|
+
fetchRole(_option, query, guildId) {
|
|
415
427
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
416
428
|
if (id && guildId)
|
|
417
|
-
return
|
|
429
|
+
return this.client.roles.raw(guildId, id);
|
|
418
430
|
return null;
|
|
419
431
|
}
|
|
420
432
|
async runGlobalMiddlewares(command, context) {
|
|
@@ -433,7 +445,9 @@ class HandleCommand {
|
|
|
433
445
|
try {
|
|
434
446
|
await command.onInternalError?.(this.client, command, e);
|
|
435
447
|
}
|
|
436
|
-
catch {
|
|
448
|
+
catch {
|
|
449
|
+
// http 418
|
|
450
|
+
}
|
|
437
451
|
}
|
|
438
452
|
return false;
|
|
439
453
|
}
|
|
@@ -453,7 +467,9 @@ class HandleCommand {
|
|
|
453
467
|
try {
|
|
454
468
|
await command.onInternalError?.(this.client, command, e);
|
|
455
469
|
}
|
|
456
|
-
catch {
|
|
470
|
+
catch {
|
|
471
|
+
// http 418
|
|
472
|
+
}
|
|
457
473
|
}
|
|
458
474
|
return false;
|
|
459
475
|
}
|
|
@@ -478,7 +494,9 @@ class HandleCommand {
|
|
|
478
494
|
try {
|
|
479
495
|
await command.onInternalError?.(this.client, command, e);
|
|
480
496
|
}
|
|
481
|
-
catch {
|
|
497
|
+
catch {
|
|
498
|
+
// http 418
|
|
499
|
+
}
|
|
482
500
|
}
|
|
483
501
|
return false;
|
|
484
502
|
}
|
|
@@ -513,13 +531,14 @@ class HandleCommand {
|
|
|
513
531
|
if (channel) {
|
|
514
532
|
if ('channel_types' in i) {
|
|
515
533
|
if (!i.channel_types.includes(channel.type)) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
534
|
+
if (i.required)
|
|
535
|
+
errors.push({
|
|
536
|
+
name: i.name,
|
|
537
|
+
error: `The entered channel type is not one of ${i
|
|
538
|
+
.channel_types.map(t => types_1.ChannelType[t])
|
|
539
|
+
.join(', ')}`,
|
|
540
|
+
fullError: ['CHANNEL_TYPES', i.channel_types],
|
|
541
|
+
});
|
|
523
542
|
break;
|
|
524
543
|
}
|
|
525
544
|
}
|
|
@@ -601,22 +620,24 @@ class HandleCommand {
|
|
|
601
620
|
if (option.min_length) {
|
|
602
621
|
if (value.length < option.min_length) {
|
|
603
622
|
value = undefined;
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
623
|
+
if (i.required)
|
|
624
|
+
errors.push({
|
|
625
|
+
name: i.name,
|
|
626
|
+
error: `The entered string has less than ${option.min_length} characters. The minimum required is ${option.min_length} characters.`,
|
|
627
|
+
fullError: ['STRING_MIN_LENGTH', option.min_length],
|
|
628
|
+
});
|
|
609
629
|
break;
|
|
610
630
|
}
|
|
611
631
|
}
|
|
612
632
|
if (option.max_length) {
|
|
613
633
|
if (value.length > option.max_length) {
|
|
614
634
|
value = undefined;
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
635
|
+
if (i.required)
|
|
636
|
+
errors.push({
|
|
637
|
+
name: i.name,
|
|
638
|
+
error: `The entered string has more than ${option.max_length} characters. The maximum required is ${option.max_length} characters.`,
|
|
639
|
+
fullError: ['STRING_MAX_LENGTH', option.max_length],
|
|
640
|
+
});
|
|
620
641
|
break;
|
|
621
642
|
}
|
|
622
643
|
}
|
|
@@ -624,13 +645,14 @@ class HandleCommand {
|
|
|
624
645
|
const choice = option.choices.find(x => x.name === value);
|
|
625
646
|
if (!choice) {
|
|
626
647
|
value = undefined;
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
.
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
648
|
+
if (i.required)
|
|
649
|
+
errors.push({
|
|
650
|
+
name: i.name,
|
|
651
|
+
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
652
|
+
.map(x => x.name)
|
|
653
|
+
.join(', ')}.`,
|
|
654
|
+
fullError: ['STRING_INVALID_CHOICE', option.choices],
|
|
655
|
+
});
|
|
634
656
|
break;
|
|
635
657
|
}
|
|
636
658
|
value = choice.value;
|
|
@@ -649,32 +671,35 @@ class HandleCommand {
|
|
|
649
671
|
}
|
|
650
672
|
if (Number.isNaN(value)) {
|
|
651
673
|
value = undefined;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
674
|
+
if (i.required)
|
|
675
|
+
errors.push({
|
|
676
|
+
name: i.name,
|
|
677
|
+
error: 'The entered choice is an invalid number.',
|
|
678
|
+
fullError: ['NUMBER_NAN', args[i.name]],
|
|
679
|
+
});
|
|
657
680
|
break;
|
|
658
681
|
}
|
|
659
682
|
if (option.min_value) {
|
|
660
683
|
if (value < option.min_value) {
|
|
661
684
|
value = undefined;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
685
|
+
if (i.required)
|
|
686
|
+
errors.push({
|
|
687
|
+
name: i.name,
|
|
688
|
+
error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
|
|
689
|
+
fullError: ['NUMBER_MIN_VALUE', option.min_value],
|
|
690
|
+
});
|
|
667
691
|
break;
|
|
668
692
|
}
|
|
669
693
|
}
|
|
670
694
|
if (option.max_value) {
|
|
671
695
|
if (value > option.max_value) {
|
|
672
696
|
value = undefined;
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
697
|
+
if (i.required)
|
|
698
|
+
errors.push({
|
|
699
|
+
name: i.name,
|
|
700
|
+
error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
|
|
701
|
+
fullError: ['NUMBER_MAX_VALUE', option.max_value],
|
|
702
|
+
});
|
|
678
703
|
break;
|
|
679
704
|
}
|
|
680
705
|
}
|
|
@@ -683,13 +708,14 @@ class HandleCommand {
|
|
|
683
708
|
const choice = option.choices.find(x => x.name === args[i.name]);
|
|
684
709
|
if (!choice) {
|
|
685
710
|
value = undefined;
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
711
|
+
if (i.required)
|
|
712
|
+
errors.push({
|
|
713
|
+
name: i.name,
|
|
714
|
+
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
715
|
+
.map(x => x.name)
|
|
716
|
+
.join(', ')}.`,
|
|
717
|
+
fullError: ['NUMBER_INVALID_CHOICE', option.choices],
|
|
718
|
+
});
|
|
693
719
|
break;
|
|
694
720
|
}
|
|
695
721
|
value = choice.value;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { EntryPointCommand } from '.';
|
|
2
2
|
import type { Logger, MakeRequired, NulleableCoalising, OmitInsert } from '../common';
|
|
3
3
|
import { BaseHandler } from '../common';
|
|
4
|
+
import { type APIApplicationCommandOption, type LocalizationMap } from '../types';
|
|
4
5
|
import { Command, type CommandOption, SubCommand } from './applications/chat';
|
|
5
6
|
import { ContextMenuCommand } from './applications/menu';
|
|
6
7
|
import type { UsingClient } from './applications/shared';
|
|
7
|
-
import type { EntryPointCommand } from '.';
|
|
8
8
|
export declare class CommandHandler extends BaseHandler {
|
|
9
9
|
protected logger: Logger;
|
|
10
10
|
protected client: UsingClient;
|
|
11
11
|
values: (Command | ContextMenuCommand)[];
|
|
12
12
|
entryPoint: EntryPointCommand | null;
|
|
13
|
-
|
|
13
|
+
filter: (path: string) => boolean;
|
|
14
14
|
constructor(logger: Logger, client: UsingClient);
|
|
15
15
|
reload(resolve: string | Command): Promise<void>;
|
|
16
16
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
17
17
|
protected shouldUploadLocales(locales?: LocalizationMap | null, cachedLocales?: LocalizationMap | null): boolean;
|
|
18
|
-
protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean
|
|
18
|
+
protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean;
|
|
19
19
|
shouldUpload(file: string, guildId?: string): Promise<boolean>;
|
|
20
20
|
set(commands: SeteableCommand[]): void;
|
|
21
21
|
load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
|
|
22
|
-
parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand |
|
|
22
|
+
parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand | SubCommand | EntryPointCommand;
|
|
23
23
|
parseGlobalLocales(command: InstanceType<HandleableCommand>): void;
|
|
24
24
|
parseCommandOptionLocales(option: MakeRequired<CommandOption, 'locales'>): void;
|
|
25
25
|
parseCommandLocales(command: Command): void;
|
package/lib/commands/handler.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandHandler = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
|
+
const Permissions_1 = require("../structures/extra/Permissions");
|
|
8
|
+
const types_1 = require("../types");
|
|
7
9
|
const chat_1 = require("./applications/chat");
|
|
8
10
|
const menu_1 = require("./applications/menu");
|
|
9
|
-
const node_fs_1 = require("node:fs");
|
|
10
11
|
class CommandHandler extends common_1.BaseHandler {
|
|
11
12
|
logger;
|
|
12
13
|
client;
|
|
@@ -89,22 +90,25 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
89
90
|
return option.channel_types.some(ct => !cached.channel_types.includes(ct));
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
break;
|
|
93
94
|
case types_1.ApplicationCommandOptionType.Subcommand:
|
|
94
95
|
case types_1.ApplicationCommandOptionType.SubcommandGroup:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
cached.options)
|
|
101
|
-
for (const i of option.options) {
|
|
102
|
-
const cachedOption = cached.options.find(x => x.name === i.name);
|
|
103
|
-
if (!cachedOption)
|
|
104
|
-
return true;
|
|
105
|
-
if (this.shouldUploadOption(i, cachedOption))
|
|
106
|
-
return true;
|
|
96
|
+
{
|
|
97
|
+
if (option.options?.length !==
|
|
98
|
+
cached.options
|
|
99
|
+
?.length) {
|
|
100
|
+
return true;
|
|
107
101
|
}
|
|
102
|
+
if (option.options &&
|
|
103
|
+
cached.options)
|
|
104
|
+
for (const i of option.options) {
|
|
105
|
+
const cachedOption = cached.options.find(x => x.name === i.name);
|
|
106
|
+
if (!cachedOption)
|
|
107
|
+
return true;
|
|
108
|
+
if (this.shouldUploadOption(i, cachedOption))
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
108
112
|
break;
|
|
109
113
|
case types_1.ApplicationCommandOptionType.Integer:
|
|
110
114
|
case types_1.ApplicationCommandOptionType.Number:
|
|
@@ -470,8 +474,8 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
470
474
|
option.onPermissionsFail?.bind(option) ??
|
|
471
475
|
commandInstance.onPermissionsFail?.bind(commandInstance) ??
|
|
472
476
|
this.client.options.commands?.defaults?.onPermissionsFail;
|
|
473
|
-
option.botPermissions
|
|
474
|
-
option.defaultMemberPermissions ??= commandInstance.defaultMemberPermissions;
|
|
477
|
+
option.botPermissions = new Permissions_1.PermissionsBitField().add(option.botPermissions ?? Permissions_1.PermissionsBitField.None, commandInstance.botPermissions);
|
|
478
|
+
option.defaultMemberPermissions ??= new Permissions_1.PermissionsBitField().add(option.defaultMemberPermissions ?? Permissions_1.PermissionsBitField.None, commandInstance.defaultMemberPermissions);
|
|
475
479
|
option.contexts ??= commandInstance.contexts;
|
|
476
480
|
option.integrationTypes ??= commandInstance.integrationTypes;
|
|
477
481
|
option.props ??= commandInstance.props;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Attachment } from '../builders';
|
|
2
|
+
import { type GuildMemberStructure, type GuildRoleStructure, type InteractionGuildMemberStructure, type UserStructure } from '../client/transformers';
|
|
2
3
|
import type { MakeRequired } from '../common';
|
|
3
4
|
import { type AllChannels } from '../structures';
|
|
5
|
+
import { type APIApplicationCommandInteractionDataOption, type APIAttachment, type APIGuildMember, type APIInteractionDataResolvedChannel, type APIInteractionGuildMember, type APIRole, type APIUser, ApplicationCommandOptionType } from '../types';
|
|
4
6
|
import type { Command, CommandAutocompleteOption, SubCommand } from './applications/chat';
|
|
5
7
|
import type { UsingClient } from './applications/shared';
|
|
6
|
-
import { type GuildMemberStructure, type GuildRoleStructure, type InteractionGuildMemberStructure, type UserStructure } from '../client/transformers';
|
|
7
|
-
import { Attachment } from '../builders';
|
|
8
8
|
export type ContextOptionsResolved = {
|
|
9
9
|
members?: Record<string, APIGuildMember | Omit<APIGuildMember, 'user'> | APIInteractionGuildMember>;
|
|
10
10
|
users?: Record<string, APIUser>;
|
|
@@ -31,7 +31,7 @@ export declare class OptionResolver {
|
|
|
31
31
|
getGroup(): string | null;
|
|
32
32
|
get(name: string): OptionResolved | undefined;
|
|
33
33
|
getHoisted(name: string): OptionResolved | undefined;
|
|
34
|
-
getValue(name: string): string | number | boolean | import("../structures").
|
|
34
|
+
getValue(name: string): string | number | boolean | import("../structures").BaseChannel<import("../types").ChannelType> | import("../structures").DMChannel | import("../structures").CategoryChannel | import("../structures").User | import("../structures").GuildMember | import("../structures").InteractionGuildMember | import("../structures").GuildRole | Attachment | undefined;
|
|
35
35
|
private getTypedOption;
|
|
36
36
|
getChannel(name: string, required?: true): AllChannels;
|
|
37
37
|
getString(name: string, required?: true): string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OptionResolver = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
const structures_1 = require("../structures");
|
|
6
|
-
const transformers_1 = require("../client/transformers");
|
|
7
4
|
const builders_1 = require("../builders");
|
|
5
|
+
const transformers_1 = require("../client/transformers");
|
|
6
|
+
const structures_1 = require("../structures");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
8
|
class OptionResolver {
|
|
9
9
|
client;
|
|
10
10
|
parent;
|
|
@@ -59,69 +59,69 @@ type Timestamp = `<t:${number}:${TimestampStyle}>`;
|
|
|
59
59
|
/**
|
|
60
60
|
* Represents a formatter utility for formatting content.
|
|
61
61
|
*/
|
|
62
|
-
export declare
|
|
62
|
+
export declare const Formatter: {
|
|
63
63
|
/**
|
|
64
64
|
* Formats a code block.
|
|
65
65
|
* @param content The content of the code block.
|
|
66
66
|
* @param language The language of the code block. Defaults to 'txt'.
|
|
67
67
|
* @returns The formatted code block.
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
codeBlock(content: string, language?: string): string;
|
|
70
70
|
/**
|
|
71
71
|
* Formats content into inline code.
|
|
72
72
|
* @param content The content to format.
|
|
73
73
|
* @returns The formatted content.
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
inlineCode(content: string): `\`${string}\``;
|
|
76
76
|
/**
|
|
77
77
|
* Formats content into bold text.
|
|
78
78
|
* @param content The content to format.
|
|
79
79
|
* @returns The formatted content.
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
bold(content: string): `**${string}**`;
|
|
82
82
|
/**
|
|
83
83
|
* Formats content into italic text.
|
|
84
84
|
* @param content The content to format.
|
|
85
85
|
* @returns The formatted content.
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
italic(content: string): `*${string}*`;
|
|
88
88
|
/**
|
|
89
89
|
* Formats content into underlined text.
|
|
90
90
|
* @param content The content to format.
|
|
91
91
|
* @returns The formatted content.
|
|
92
92
|
*/
|
|
93
|
-
|
|
93
|
+
underline(content: string): `__${string}__`;
|
|
94
94
|
/**
|
|
95
95
|
* Formats content into strikethrough text.
|
|
96
96
|
* @param content The content to format.
|
|
97
97
|
* @returns The formatted content.
|
|
98
98
|
*/
|
|
99
|
-
|
|
99
|
+
strikeThrough(content: string): `~~${string}~~`;
|
|
100
100
|
/**
|
|
101
101
|
* Formats content into a hyperlink.
|
|
102
102
|
* @param content The content to format.
|
|
103
103
|
* @param url The URL to hyperlink to.
|
|
104
104
|
* @returns The formatted content.
|
|
105
105
|
*/
|
|
106
|
-
|
|
106
|
+
hyperlink(content: string, url: string): `[${string}](${string})`;
|
|
107
107
|
/**
|
|
108
108
|
* Formats content into a spoiler.
|
|
109
109
|
* @param content The content to format.
|
|
110
110
|
* @returns The formatted content.
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
spoiler(content: string): `||${string}||`;
|
|
113
113
|
/**
|
|
114
114
|
* Formats content into a quote.
|
|
115
115
|
* @param content The content to format.
|
|
116
116
|
* @returns The formatted content.
|
|
117
117
|
*/
|
|
118
|
-
|
|
118
|
+
blockQuote(content: string): string;
|
|
119
119
|
/**
|
|
120
120
|
* Formats content into a quote.
|
|
121
121
|
* @param content The content to format.
|
|
122
122
|
* @returns The formatted content.
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
quote(content: string): string;
|
|
125
125
|
/**
|
|
126
126
|
* Formats a message link.
|
|
127
127
|
* @param guildId The ID of the guild.
|
|
@@ -129,59 +129,59 @@ export declare class Formatter {
|
|
|
129
129
|
* @param messageId The ID of the message.
|
|
130
130
|
* @returns The formatted message link.
|
|
131
131
|
*/
|
|
132
|
-
|
|
132
|
+
messageLink(guildId: string, channelId: string, messageId: string): MessageLink;
|
|
133
133
|
/**
|
|
134
134
|
* Formats a header.
|
|
135
135
|
* @param content The content of the header.
|
|
136
136
|
* @param level The level of the header. Defaults to 1.
|
|
137
137
|
* @returns The formatted header.
|
|
138
138
|
*/
|
|
139
|
-
|
|
139
|
+
header(content: string, level?: HeadingLevel): string;
|
|
140
140
|
/**
|
|
141
141
|
* Formats a list.
|
|
142
142
|
* @param items The items of the list.
|
|
143
143
|
* @param ordered Whether the list is ordered. Defaults to false.
|
|
144
144
|
* @returns The formatted list.
|
|
145
145
|
*/
|
|
146
|
-
|
|
146
|
+
list(items: string[], ordered?: boolean): string;
|
|
147
147
|
/**
|
|
148
148
|
* Formats the given timestamp into discord unix timestamp format.
|
|
149
149
|
* @param timestamp The timestamp to format.
|
|
150
150
|
* @param style The style of the timestamp. Defaults to 't'.
|
|
151
151
|
* @returns The formatted timestamp.
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
timestamp(timestamp: Date, style?: TimestampStyle): Timestamp;
|
|
154
154
|
/**
|
|
155
155
|
* Formats a user mention.
|
|
156
156
|
* @param userId The ID of the user to mention.
|
|
157
157
|
* @returns The formatted user mention.
|
|
158
158
|
*/
|
|
159
|
-
|
|
159
|
+
userMention(userId: string): `<@${string}>`;
|
|
160
160
|
/**
|
|
161
161
|
* Formats a role mention.
|
|
162
162
|
* @param roleId The ID of the role to mention.
|
|
163
163
|
* @returns The formatted role mention.
|
|
164
164
|
*/
|
|
165
|
-
|
|
165
|
+
roleMention(roleId: string): `<@&${string}>`;
|
|
166
166
|
/**
|
|
167
167
|
* Formats a channel mention.
|
|
168
168
|
* @param channelId The ID of the channel to mention.
|
|
169
169
|
* @returns The formatted channel mention.
|
|
170
170
|
*/
|
|
171
|
-
|
|
171
|
+
channelMention(channelId: string): `<#${string}>`;
|
|
172
172
|
/**
|
|
173
173
|
* Formats an emoji.
|
|
174
174
|
* @param emojiId The ID of the emoji.
|
|
175
175
|
* @param animated Whether the emoji is animated. Defaults to false.
|
|
176
176
|
* @returns The formatted emoji.
|
|
177
177
|
*/
|
|
178
|
-
|
|
178
|
+
emojiMention(emojiId: string, name: string | null, animated?: boolean): string;
|
|
179
179
|
/**
|
|
180
180
|
* Formats a channel link.
|
|
181
181
|
* @param channelId The ID of the channel.
|
|
182
182
|
* @param guildId The ID of the guild. Defaults to '@me'.
|
|
183
183
|
* @returns The formatted channel link.
|
|
184
184
|
*/
|
|
185
|
-
|
|
186
|
-
}
|
|
185
|
+
channelLink(channelId: string, guildId?: string): string;
|
|
186
|
+
};
|
|
187
187
|
export {};
|