seyfert 2.0.0 → 2.1.1-dev-11310514874.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 +9 -3
- package/lib/api/Routes/invites.d.ts +3 -4
- package/lib/api/Routes/skus.d.ts +10 -0
- package/lib/api/Routes/skus.js +2 -0
- 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 +26 -22
- package/lib/api/shared.d.ts +2 -2
- package/lib/api/utils/constants.d.ts +3 -1
- package/lib/api/utils/constants.js +3 -2
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/Attachment.d.ts +3 -3
- package/lib/builders/Attachment.js +13 -13
- 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 +12 -12
- package/lib/cache/index.js +48 -39
- 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 +10 -15
- package/lib/client/base.js +48 -44
- package/lib/client/client.d.ts +4 -4
- package/lib/client/client.js +37 -38
- package/lib/client/collectors.js +1 -1
- package/lib/client/httpclient.d.ts +1 -1
- package/lib/client/httpclient.js +2 -2
- package/lib/client/transformers.d.ts +37 -34
- package/lib/client/transformers.js +66 -63
- package/lib/client/workerclient.d.ts +13 -13
- package/lib/client/workerclient.js +182 -65
- package/lib/collection.d.ts +3 -3
- package/lib/commands/applications/chat.d.ts +3 -3
- 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 +46 -0
- package/lib/commands/applications/entryPoint.js +56 -0
- package/lib/commands/applications/entrycontext.d.ts +40 -0
- package/lib/commands/applications/entrycontext.js +85 -0
- 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 +7 -6
- package/lib/commands/applications/shared.d.ts +5 -2
- package/lib/commands/basecontext.d.ts +1 -1
- package/lib/commands/decorators.d.ts +20 -26
- package/lib/commands/decorators.js +8 -4
- package/lib/commands/handle.d.ts +13 -12
- package/lib/commands/handle.js +133 -65
- package/lib/commands/handler.d.ts +9 -7
- package/lib/commands/handler.js +27 -18
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/optionresolver.d.ts +4 -4
- package/lib/commands/optionresolver.js +4 -4
- package/lib/common/bot/watcher.d.ts +1 -1
- 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 +14 -6
- package/lib/common/it/utils.js +62 -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 +3 -3
- 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/deps/mixer.js +6 -1
- package/lib/events/handler.d.ts +5 -5
- package/lib/events/handler.js +69 -19
- 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/custom.d.ts +1 -0
- package/lib/events/hooks/custom.js +5 -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/subscriptions.d.ts +35 -0
- package/lib/events/hooks/subscriptions.js +16 -0
- 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 +39 -16
- package/lib/structures/Interaction.js +82 -26
- package/lib/structures/Message.d.ts +4 -10
- package/lib/structures/Message.js +5 -8
- 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 +8 -7
- package/lib/structures/extra/BaseGuild.d.ts +11 -1
- package/lib/structures/extra/BaseGuild.js +27 -0
- 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 +71 -6
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +6 -1
- package/lib/types/payloads/_interactions/applicationCommands.d.ts +41 -6
- package/lib/types/payloads/_interactions/applicationCommands.js +28 -1
- package/lib/types/payloads/_interactions/base.d.ts +1 -1
- package/lib/types/payloads/_interactions/responses.d.ts +74 -2
- package/lib/types/payloads/_interactions/responses.js +4 -0
- package/lib/types/payloads/channel.d.ts +46 -6
- package/lib/types/payloads/channel.js +5 -1
- 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/monetization.d.ts +29 -1
- package/lib/types/payloads/monetization.js +10 -1
- 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 +5 -18
- 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/interactions.d.ts +30 -8
- package/lib/types/rest/monetization.d.ts +22 -1
- 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 +3 -3
- package/lib/types/utils/index.d.ts +27 -7
- package/lib/types/utils/index.js +25 -6
- package/lib/websocket/SharedTypes.d.ts +18 -3
- package/lib/websocket/constants/index.d.ts +3 -2
- package/lib/websocket/constants/index.js +4 -4
- package/lib/websocket/discord/basesocket.d.ts +1 -1
- package/lib/websocket/discord/shard.d.ts +4 -3
- package/lib/websocket/discord/shard.js +47 -24
- package/lib/websocket/discord/sharder.d.ts +9 -6
- package/lib/websocket/discord/sharder.js +92 -17
- package/lib/websocket/discord/shared.d.ts +12 -3
- package/lib/websocket/discord/socket/custom.d.ts +1 -1
- package/lib/websocket/discord/socket/custom.js +70 -40
- package/lib/websocket/discord/worker.d.ts +9 -2
- package/lib/websocket/discord/workermanager.d.ts +42 -16
- package/lib/websocket/discord/workermanager.js +170 -46
- package/lib/websocket/structures/timeout.d.ts +4 -5
- package/lib/websocket/structures/timeout.js +23 -24
- package/package.json +72 -65
- 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);
|
|
@@ -70,11 +70,49 @@ class HandleCommand {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
async
|
|
74
|
-
if (command.botPermissions && interaction.appPermissions) {
|
|
73
|
+
async entryPoint(command, interaction, context) {
|
|
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
|
+
}
|
|
79
|
+
const resultGlobal = await this.runGlobalMiddlewares(command, context);
|
|
80
|
+
if (typeof resultGlobal === 'boolean')
|
|
81
|
+
return;
|
|
82
|
+
const resultMiddle = await this.runMiddlewares(command, context);
|
|
83
|
+
if (typeof resultMiddle === 'boolean')
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
try {
|
|
87
|
+
await command.run(context);
|
|
88
|
+
await command.onAfterRun?.(context, undefined);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
await command.onRunError(context, error);
|
|
92
|
+
await command.onAfterRun?.(context, error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
try {
|
|
97
|
+
await command.onInternalError(this.client, command, error);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// pass
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async chatInput(command, interaction, resolver, context) {
|
|
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
|
+
}
|
|
78
116
|
}
|
|
79
117
|
if (!(await this.runOptions(command, context, resolver)))
|
|
80
118
|
return;
|
|
@@ -133,8 +171,9 @@ class HandleCommand {
|
|
|
133
171
|
const data = this.makeMenuCommand(body, shardId, __reply);
|
|
134
172
|
if (!data)
|
|
135
173
|
return;
|
|
174
|
+
this.contextMenuMessage(data.command,
|
|
136
175
|
// @ts-expect-error
|
|
137
|
-
|
|
176
|
+
data.interaction, data.context);
|
|
138
177
|
break;
|
|
139
178
|
}
|
|
140
179
|
case types_1.ApplicationCommandType.User: {
|
|
@@ -145,6 +184,17 @@ class HandleCommand {
|
|
|
145
184
|
this.contextMenuUser(data.command, data.interaction, data.context);
|
|
146
185
|
break;
|
|
147
186
|
}
|
|
187
|
+
case types_1.ApplicationCommandType.PrimaryEntryPoint: {
|
|
188
|
+
const command = this.client.commands?.entryPoint;
|
|
189
|
+
if (!command?.run)
|
|
190
|
+
return;
|
|
191
|
+
const interaction = structures_1.BaseInteraction.from(this.client, body, __reply);
|
|
192
|
+
const context = new _1.EntryPointContext(this.client, interaction, shardId, command);
|
|
193
|
+
const extendContext = this.client.options?.context?.(interaction) ?? {};
|
|
194
|
+
Object.assign(context, extendContext);
|
|
195
|
+
await this.entryPoint(command, interaction, context);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
148
198
|
case types_1.ApplicationCommandType.ChatInput: {
|
|
149
199
|
const parentCommand = this.getCommand(body.data);
|
|
150
200
|
const optionsResolver = this.makeResolver(this.client, body.data.options ?? [], parentCommand, body.guild_id, body.data.resolved);
|
|
@@ -243,7 +293,7 @@ class HandleCommand {
|
|
|
243
293
|
if (command.botPermissions) {
|
|
244
294
|
const appPermissions = await self.members.permissions(rawMessage.guild_id, self.botId);
|
|
245
295
|
const permissions = this.checkPermissions(appPermissions, command.botPermissions);
|
|
246
|
-
if (
|
|
296
|
+
if (permissions) {
|
|
247
297
|
return command.onBotPermissionsFail?.(context, permissions);
|
|
248
298
|
}
|
|
249
299
|
}
|
|
@@ -269,7 +319,9 @@ class HandleCommand {
|
|
|
269
319
|
try {
|
|
270
320
|
await command.onInternalError?.(this.client, command, error);
|
|
271
321
|
}
|
|
272
|
-
catch {
|
|
322
|
+
catch {
|
|
323
|
+
// http 418
|
|
324
|
+
}
|
|
273
325
|
}
|
|
274
326
|
}
|
|
275
327
|
argsParser(content, _command, _message) {
|
|
@@ -345,34 +397,36 @@ class HandleCommand {
|
|
|
345
397
|
});
|
|
346
398
|
}
|
|
347
399
|
checkPermissions(app, bot) {
|
|
400
|
+
if (app.has('Administrator'))
|
|
401
|
+
return;
|
|
348
402
|
const permissions = app.missings(...app.values([bot]));
|
|
349
|
-
if (
|
|
403
|
+
if (permissions.length) {
|
|
350
404
|
return app.keys(permissions);
|
|
351
405
|
}
|
|
352
406
|
return;
|
|
353
407
|
}
|
|
354
|
-
|
|
408
|
+
fetchChannel(_option, query) {
|
|
355
409
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
356
410
|
if (id)
|
|
357
411
|
return this.client.channels.raw(id);
|
|
358
412
|
return null;
|
|
359
413
|
}
|
|
360
|
-
|
|
414
|
+
fetchUser(_option, query) {
|
|
361
415
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
362
416
|
if (id)
|
|
363
417
|
return this.client.users.raw(id);
|
|
364
418
|
return null;
|
|
365
419
|
}
|
|
366
|
-
|
|
420
|
+
fetchMember(_option, query, guildId) {
|
|
367
421
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
368
422
|
if (id)
|
|
369
423
|
return this.client.members.raw(guildId, id);
|
|
370
424
|
return null;
|
|
371
425
|
}
|
|
372
|
-
|
|
426
|
+
fetchRole(_option, query, guildId) {
|
|
373
427
|
const id = query.match(/[0-9]{17,19}/g)?.[0];
|
|
374
428
|
if (id && guildId)
|
|
375
|
-
return
|
|
429
|
+
return this.client.roles.raw(guildId, id);
|
|
376
430
|
return null;
|
|
377
431
|
}
|
|
378
432
|
async runGlobalMiddlewares(command, context) {
|
|
@@ -391,7 +445,9 @@ class HandleCommand {
|
|
|
391
445
|
try {
|
|
392
446
|
await command.onInternalError?.(this.client, command, e);
|
|
393
447
|
}
|
|
394
|
-
catch {
|
|
448
|
+
catch {
|
|
449
|
+
// http 418
|
|
450
|
+
}
|
|
395
451
|
}
|
|
396
452
|
return false;
|
|
397
453
|
}
|
|
@@ -411,7 +467,9 @@ class HandleCommand {
|
|
|
411
467
|
try {
|
|
412
468
|
await command.onInternalError?.(this.client, command, e);
|
|
413
469
|
}
|
|
414
|
-
catch {
|
|
470
|
+
catch {
|
|
471
|
+
// http 418
|
|
472
|
+
}
|
|
415
473
|
}
|
|
416
474
|
return false;
|
|
417
475
|
}
|
|
@@ -436,7 +494,9 @@ class HandleCommand {
|
|
|
436
494
|
try {
|
|
437
495
|
await command.onInternalError?.(this.client, command, e);
|
|
438
496
|
}
|
|
439
|
-
catch {
|
|
497
|
+
catch {
|
|
498
|
+
// http 418
|
|
499
|
+
}
|
|
440
500
|
}
|
|
441
501
|
return false;
|
|
442
502
|
}
|
|
@@ -471,13 +531,14 @@ class HandleCommand {
|
|
|
471
531
|
if (channel) {
|
|
472
532
|
if ('channel_types' in i) {
|
|
473
533
|
if (!i.channel_types.includes(channel.type)) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
+
});
|
|
481
542
|
break;
|
|
482
543
|
}
|
|
483
544
|
}
|
|
@@ -559,22 +620,24 @@ class HandleCommand {
|
|
|
559
620
|
if (option.min_length) {
|
|
560
621
|
if (value.length < option.min_length) {
|
|
561
622
|
value = undefined;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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
|
+
});
|
|
567
629
|
break;
|
|
568
630
|
}
|
|
569
631
|
}
|
|
570
632
|
if (option.max_length) {
|
|
571
633
|
if (value.length > option.max_length) {
|
|
572
634
|
value = undefined;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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
|
+
});
|
|
578
641
|
break;
|
|
579
642
|
}
|
|
580
643
|
}
|
|
@@ -582,13 +645,14 @@ class HandleCommand {
|
|
|
582
645
|
const choice = option.choices.find(x => x.name === value);
|
|
583
646
|
if (!choice) {
|
|
584
647
|
value = undefined;
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
.
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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
|
+
});
|
|
592
656
|
break;
|
|
593
657
|
}
|
|
594
658
|
value = choice.value;
|
|
@@ -607,32 +671,35 @@ class HandleCommand {
|
|
|
607
671
|
}
|
|
608
672
|
if (Number.isNaN(value)) {
|
|
609
673
|
value = undefined;
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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
|
+
});
|
|
615
680
|
break;
|
|
616
681
|
}
|
|
617
682
|
if (option.min_value) {
|
|
618
683
|
if (value < option.min_value) {
|
|
619
684
|
value = undefined;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
+
});
|
|
625
691
|
break;
|
|
626
692
|
}
|
|
627
693
|
}
|
|
628
694
|
if (option.max_value) {
|
|
629
695
|
if (value > option.max_value) {
|
|
630
696
|
value = undefined;
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
+
});
|
|
636
703
|
break;
|
|
637
704
|
}
|
|
638
705
|
}
|
|
@@ -641,13 +708,14 @@ class HandleCommand {
|
|
|
641
708
|
const choice = option.choices.find(x => x.name === args[i.name]);
|
|
642
709
|
if (!choice) {
|
|
643
710
|
value = undefined;
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
.
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
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
|
+
});
|
|
651
719
|
break;
|
|
652
720
|
}
|
|
653
721
|
value = choice.value;
|
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
@@ -8,17 +9,18 @@ export declare class CommandHandler extends BaseHandler {
|
|
|
8
9
|
protected logger: Logger;
|
|
9
10
|
protected client: UsingClient;
|
|
10
11
|
values: (Command | ContextMenuCommand)[];
|
|
11
|
-
|
|
12
|
+
entryPoint: EntryPointCommand | null;
|
|
13
|
+
filter: (path: string) => boolean;
|
|
12
14
|
constructor(logger: Logger, client: UsingClient);
|
|
13
15
|
reload(resolve: string | Command): Promise<void>;
|
|
14
16
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
15
17
|
protected shouldUploadLocales(locales?: LocalizationMap | null, cachedLocales?: LocalizationMap | null): boolean;
|
|
16
|
-
protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean
|
|
18
|
+
protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean;
|
|
17
19
|
shouldUpload(file: string, guildId?: string): Promise<boolean>;
|
|
18
20
|
set(commands: SeteableCommand[]): void;
|
|
19
21
|
load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
|
|
20
|
-
parseLocales(command:
|
|
21
|
-
parseGlobalLocales(command:
|
|
22
|
+
parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand | SubCommand | EntryPointCommand;
|
|
23
|
+
parseGlobalLocales(command: InstanceType<HandleableCommand>): void;
|
|
22
24
|
parseCommandOptionLocales(option: MakeRequired<CommandOption, 'locales'>): void;
|
|
23
25
|
parseCommandLocales(command: Command): void;
|
|
24
26
|
parseContextMenuLocales(command: ContextMenuCommand): ContextMenuCommand;
|
|
@@ -29,12 +31,12 @@ export declare class CommandHandler extends BaseHandler {
|
|
|
29
31
|
}> | false;
|
|
30
32
|
stablishSubCommandDefaults(commandInstance: Command, option: SubCommand): SubCommand;
|
|
31
33
|
onFile(file: FileLoaded): HandleableCommand[] | undefined;
|
|
32
|
-
onCommand(file: HandleableCommand):
|
|
34
|
+
onCommand(file: HandleableCommand): InstanceType<HandleableCommand> | false;
|
|
33
35
|
onSubCommand(file: HandleableSubCommand): SubCommand | false;
|
|
34
36
|
}
|
|
35
37
|
export type FileLoaded<T = null> = {
|
|
36
38
|
default?: NulleableCoalising<T, HandleableCommand>;
|
|
37
39
|
} & Record<string, NulleableCoalising<T, HandleableCommand>>;
|
|
38
|
-
export type HandleableCommand = new () => Command | SubCommand | ContextMenuCommand;
|
|
40
|
+
export type HandleableCommand = new () => Command | SubCommand | ContextMenuCommand | EntryPointCommand;
|
|
39
41
|
export type SeteableCommand = new () => Extract<InstanceType<HandleableCommand>, SubCommand>;
|
|
40
42
|
export type HandleableSubCommand = new () => SubCommand;
|
package/lib/commands/handler.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
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;
|
|
13
14
|
values = [];
|
|
15
|
+
entryPoint = null;
|
|
14
16
|
filter = (path) => path.endsWith('.js') || (!path.endsWith('.d.ts') && path.endsWith('.ts'));
|
|
15
17
|
constructor(logger, client) {
|
|
16
18
|
super(logger);
|
|
@@ -88,22 +90,25 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
88
90
|
return option.channel_types.some(ct => !cached.channel_types.includes(ct));
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
|
|
93
|
+
break;
|
|
92
94
|
case types_1.ApplicationCommandOptionType.Subcommand:
|
|
93
95
|
case types_1.ApplicationCommandOptionType.SubcommandGroup:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
cached.options)
|
|
100
|
-
for (const i of option.options) {
|
|
101
|
-
const cachedOption = cached.options.find(x => x.name === i.name);
|
|
102
|
-
if (!cachedOption)
|
|
103
|
-
return true;
|
|
104
|
-
if (this.shouldUploadOption(i, cachedOption))
|
|
105
|
-
return true;
|
|
96
|
+
{
|
|
97
|
+
if (option.options?.length !==
|
|
98
|
+
cached.options
|
|
99
|
+
?.length) {
|
|
100
|
+
return true;
|
|
106
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
|
+
}
|
|
107
112
|
break;
|
|
108
113
|
case types_1.ApplicationCommandOptionType.Integer:
|
|
109
114
|
case types_1.ApplicationCommandOptionType.Number:
|
|
@@ -287,8 +292,12 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
294
|
this.stablishContextCommandDefaults(commandInstance);
|
|
290
|
-
this.values.push(commandInstance);
|
|
291
295
|
this.parseLocales(commandInstance);
|
|
296
|
+
if ('handler' in commandInstance && commandInstance.handler) {
|
|
297
|
+
this.entryPoint = commandInstance;
|
|
298
|
+
}
|
|
299
|
+
else
|
|
300
|
+
this.values.push(commandInstance);
|
|
292
301
|
}
|
|
293
302
|
}
|
|
294
303
|
return this.values;
|
|
@@ -465,8 +474,8 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
465
474
|
option.onPermissionsFail?.bind(option) ??
|
|
466
475
|
commandInstance.onPermissionsFail?.bind(commandInstance) ??
|
|
467
476
|
this.client.options.commands?.defaults?.onPermissionsFail;
|
|
468
|
-
option.botPermissions
|
|
469
|
-
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);
|
|
470
479
|
option.contexts ??= commandInstance.contexts;
|
|
471
480
|
option.integrationTypes ??= commandInstance.integrationTypes;
|
|
472
481
|
option.props ??= commandInstance.props;
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export * from './applications/chatcontext';
|
|
|
4
4
|
export * from './applications/menu';
|
|
5
5
|
export * from './applications/menucontext';
|
|
6
6
|
export * from './applications/options';
|
|
7
|
+
export * from './applications/entryPoint';
|
|
8
|
+
export * from './applications/entrycontext';
|
|
7
9
|
export * from './decorators';
|
|
8
10
|
export * from './optionresolver';
|
package/lib/commands/index.js
CHANGED
|
@@ -21,5 +21,7 @@ __exportStar(require("./applications/chatcontext"), exports);
|
|
|
21
21
|
__exportStar(require("./applications/menu"), exports);
|
|
22
22
|
__exportStar(require("./applications/menucontext"), exports);
|
|
23
23
|
__exportStar(require("./applications/options"), exports);
|
|
24
|
+
__exportStar(require("./applications/entryPoint"), exports);
|
|
25
|
+
__exportStar(require("./applications/entrycontext"), exports);
|
|
24
26
|
__exportStar(require("./decorators"), exports);
|
|
25
27
|
__exportStar(require("./optionresolver"), exports);
|
|
@@ -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;
|
|
@@ -43,7 +43,7 @@ class OptionResolver {
|
|
|
43
43
|
return this.hoistedOptions.find(option => option.focused)?.value;
|
|
44
44
|
}
|
|
45
45
|
getAutocomplete() {
|
|
46
|
-
return
|
|
46
|
+
return this.getCommand()?.options?.find(option => option.name === this.hoistedOptions.find(x => x.focused)?.name);
|
|
47
47
|
}
|
|
48
48
|
getParent() {
|
|
49
49
|
return this.parent?.name;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GatewayDispatchPayload, GatewaySendPayload } from '../../types';
|
|
2
2
|
import type { ShardManager, ShardManagerOptions } from '../../websocket';
|
|
3
3
|
import type { MakePartial } from '../types/util';
|
|
4
|
-
export interface WatcherOptions extends MakePartial<Omit<ShardManager['options'], 'handlePayload' | 'info' | 'token' | 'intents'>, 'compress' | 'presence' | 'properties' | 'shardEnd' | 'shardStart' | 'spawnShardDelay' | 'totalShards' | 'url' | 'version'> {
|
|
4
|
+
export interface WatcherOptions extends MakePartial<Omit<ShardManager['options'], 'handlePayload' | 'info' | 'token' | 'intents'>, 'compress' | 'presence' | 'properties' | 'shardEnd' | 'shardStart' | 'spawnShardDelay' | 'totalShards' | 'url' | 'version' | 'resharding' | 'debug'> {
|
|
5
5
|
filePath: string;
|
|
6
6
|
transpileCommand: string;
|
|
7
7
|
srcPath: string;
|