seyfert 4.5.0 → 5.0.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/Routes/cdn.d.ts +2 -2
- package/lib/api/Routes/guilds.d.ts +2 -2
- package/lib/api/Routes/invites.d.ts +2 -2
- package/lib/api/api.d.ts +20 -8
- package/lib/api/api.js +198 -44
- package/lib/api/shared.d.ts +30 -1
- package/lib/api/utils/constants.d.ts +1 -1
- package/lib/api/utils/constants.js +1 -1
- package/lib/api/utils/utils.d.ts +2 -1
- package/lib/api/utils/utils.js +1 -1
- package/lib/builders/Attachment.d.ts +1 -1
- package/lib/builders/Attachment.js +30 -8
- package/lib/builders/MediaGallery.d.ts +2 -2
- package/lib/builders/MediaGallery.js +10 -0
- package/lib/builders/Modal.d.ts +18 -8
- package/lib/builders/Modal.js +36 -7
- package/lib/builders/Poll.js +18 -0
- package/lib/builders/RadioGroup.d.ts +4 -3
- package/lib/builders/RadioGroup.js +24 -3
- package/lib/builders/SelectMenu.d.ts +8 -6
- package/lib/builders/SelectMenu.js +24 -3
- package/lib/builders/types.d.ts +3 -2
- package/lib/cache/adapters/default.d.ts +1 -1
- package/lib/cache/adapters/default.js +23 -26
- package/lib/cache/adapters/limited.d.ts +1 -0
- package/lib/cache/adapters/limited.js +47 -33
- package/lib/cache/index.d.ts +19 -25
- package/lib/cache/index.js +58 -6
- package/lib/cache/resources/bans.d.ts +1 -1
- package/lib/cache/resources/bans.js +4 -4
- package/lib/cache/resources/channels.d.ts +1 -1
- package/lib/cache/resources/channels.js +4 -4
- package/lib/cache/resources/default/base.d.ts +1 -1
- package/lib/cache/resources/default/base.js +8 -8
- package/lib/cache/resources/default/guild-based.d.ts +5 -5
- package/lib/cache/resources/default/guild-based.js +29 -16
- package/lib/cache/resources/default/guild-related.d.ts +5 -5
- package/lib/cache/resources/default/guild-related.js +14 -14
- package/lib/cache/resources/emojis.d.ts +1 -1
- package/lib/cache/resources/emojis.js +4 -4
- package/lib/cache/resources/guilds.js +28 -15
- package/lib/cache/resources/members.d.ts +1 -1
- package/lib/cache/resources/members.js +6 -6
- package/lib/cache/resources/messages.d.ts +7 -2
- package/lib/cache/resources/messages.js +43 -20
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +5 -8
- package/lib/cache/resources/roles.d.ts +1 -1
- package/lib/cache/resources/roles.js +4 -4
- package/lib/cache/resources/stickers.d.ts +1 -1
- package/lib/cache/resources/stickers.js +4 -4
- package/lib/cache/resources/users.js +4 -4
- package/lib/cache/resources/voice-states.d.ts +1 -1
- package/lib/cache/resources/voice-states.js +4 -4
- package/lib/client/base.d.ts +83 -24
- package/lib/client/base.js +594 -39
- package/lib/client/client.d.ts +28 -3
- package/lib/client/client.js +33 -9
- package/lib/client/collectors.d.ts +9 -8
- package/lib/client/collectors.js +19 -52
- package/lib/client/httpclient.d.ts +3 -0
- package/lib/client/index.d.ts +3 -1
- package/lib/client/index.js +4 -0
- package/lib/client/intents.d.ts +3 -0
- package/lib/client/intents.js +9 -0
- package/lib/client/plugins/api.d.ts +4 -0
- package/lib/client/plugins/api.js +550 -0
- package/lib/client/plugins/errors.d.ts +25 -0
- package/lib/client/plugins/errors.js +79 -0
- package/lib/client/plugins/order.d.ts +10 -0
- package/lib/client/plugins/order.js +32 -0
- package/lib/client/plugins/registry.d.ts +273 -0
- package/lib/client/plugins/registry.js +868 -0
- package/lib/client/plugins/shared.d.ts +23 -0
- package/lib/client/plugins/shared.js +193 -0
- package/lib/client/plugins/types.d.ts +398 -0
- package/lib/client/plugins/types.js +8 -0
- package/lib/client/plugins.d.ts +78 -0
- package/lib/client/plugins.js +558 -0
- package/lib/client/transformers.d.ts +33 -33
- package/lib/client/workerclient.d.ts +10 -1
- package/lib/client/workerclient.js +27 -17
- package/lib/collection.d.ts +10 -8
- package/lib/collection.js +19 -25
- package/lib/commands/applications/chat.d.ts +20 -18
- package/lib/commands/applications/chat.js +39 -14
- package/lib/commands/applications/chatcontext.d.ts +23 -15
- package/lib/commands/applications/chatcontext.js +23 -2
- package/lib/commands/applications/entryPoint.d.ts +4 -3
- package/lib/commands/applications/entryPoint.js +1 -1
- package/lib/commands/applications/entrycontext.d.ts +7 -9
- package/lib/commands/applications/entrycontext.js +3 -1
- package/lib/commands/applications/menu.d.ts +4 -3
- package/lib/commands/applications/menucontext.d.ts +7 -9
- package/lib/commands/applications/menucontext.js +3 -1
- package/lib/commands/applications/options.d.ts +23 -23
- package/lib/commands/applications/shared.d.ts +39 -17
- package/lib/commands/decorators.d.ts +50 -38
- package/lib/commands/decorators.js +15 -5
- package/lib/commands/handle.d.ts +19 -8
- package/lib/commands/handle.js +224 -143
- package/lib/commands/handler.d.ts +21 -8
- package/lib/commands/handler.js +157 -69
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/optionresolver.d.ts +2 -2
- package/lib/common/it/colors.js +12 -2
- package/lib/common/it/error.d.ts +9 -0
- package/lib/common/it/error.js +8 -0
- package/lib/common/it/fake-promise.d.ts +4 -0
- package/lib/common/it/fake-promise.js +10 -0
- package/lib/common/it/formatter.d.ts +14 -11
- package/lib/common/it/formatter.js +4 -3
- package/lib/common/it/logger.d.ts +7 -1
- package/lib/common/it/logger.js +24 -6
- package/lib/common/it/utils.d.ts +6 -8
- package/lib/common/it/utils.js +44 -42
- package/lib/common/shorters/application.d.ts +3 -3
- package/lib/common/shorters/application.js +3 -2
- package/lib/common/shorters/bans.d.ts +8 -4
- package/lib/common/shorters/bans.js +13 -5
- package/lib/common/shorters/channels.d.ts +4 -4
- package/lib/common/shorters/channels.js +4 -4
- package/lib/common/shorters/emojis.js +1 -0
- package/lib/common/shorters/guilds.d.ts +8 -8
- package/lib/common/shorters/guilds.js +14 -31
- package/lib/common/shorters/interaction.d.ts +1 -1
- package/lib/common/shorters/invites.d.ts +201 -201
- package/lib/common/shorters/members.d.ts +7 -7
- package/lib/common/shorters/members.js +13 -14
- package/lib/common/shorters/messages.d.ts +2 -2
- package/lib/common/shorters/soundboard.d.ts +5 -5
- package/lib/common/shorters/users.d.ts +1 -1
- package/lib/common/shorters/webhook.d.ts +3 -2
- package/lib/common/shorters/webhook.js +0 -7
- package/lib/common/types/options.d.ts +4 -0
- package/lib/common/types/util.d.ts +8 -0
- package/lib/common/types/write.d.ts +2 -1
- package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
- package/lib/components/BaseSelectMenuComponent.js +1 -1
- package/lib/components/ButtonComponent.d.ts +3 -3
- package/lib/components/ChannelSelectMenuComponent.d.ts +2 -2
- package/lib/components/File.d.ts +1 -1
- package/lib/components/MediaGallery.d.ts +1 -1
- package/lib/components/MentionableSelectMenuComponent.d.ts +1 -1
- package/lib/components/RoleSelectMenuComponent.d.ts +1 -1
- package/lib/components/Separator.d.ts +1 -1
- package/lib/components/StringSelectMenuComponent.d.ts +1 -1
- package/lib/components/TextInputComponent.d.ts +1 -1
- package/lib/components/Thumbnail.d.ts +1 -1
- package/lib/components/UserSelectMenuComponent.d.ts +1 -1
- package/lib/components/componentcommand.d.ts +8 -7
- package/lib/components/componentcontext.d.ts +24 -36
- package/lib/components/componentcontext.js +7 -17
- package/lib/components/handler.d.ts +17 -7
- package/lib/components/handler.js +108 -49
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/interactioncontext.d.ts +45 -0
- package/lib/components/interactioncontext.js +93 -0
- package/lib/components/modalcommand.d.ts +5 -4
- package/lib/components/modalcontext.d.ts +39 -20
- package/lib/components/modalcontext.js +59 -6
- package/lib/events/event.d.ts +9 -3
- package/lib/events/handler.d.ts +51 -6
- package/lib/events/handler.js +165 -36
- package/lib/events/hooks/application_command.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.d.ts +2 -2
- package/lib/events/hooks/guild.d.ts +150 -150
- package/lib/events/hooks/interactions.d.ts +1 -1
- package/lib/events/hooks/invite.d.ts +20 -20
- package/lib/events/hooks/message.d.ts +27 -27
- package/lib/events/hooks/presence.d.ts +11 -11
- package/lib/events/hooks/soundboard.d.ts +6 -6
- package/lib/events/hooks/stage.d.ts +2 -2
- package/lib/events/hooks/subscriptions.d.ts +3 -3
- package/lib/events/hooks/thread.d.ts +30 -30
- package/lib/events/hooks/voice.d.ts +3 -4
- package/lib/events/hooks/voice.js +2 -1
- package/lib/events/utils.d.ts +4 -0
- package/lib/events/utils.js +59 -0
- package/lib/index.d.ts +9 -4
- package/lib/index.js +13 -8
- package/lib/langs/handler.d.ts +14 -11
- package/lib/langs/handler.js +46 -9
- package/lib/langs/router.d.ts +10 -3
- package/lib/structures/Application.d.ts +1 -1
- package/lib/structures/Emoji.d.ts +3 -3
- package/lib/structures/Emoji.js +2 -2
- package/lib/structures/Guild.d.ts +154 -154
- package/lib/structures/GuildBan.d.ts +4 -4
- package/lib/structures/GuildBan.js +3 -3
- package/lib/structures/GuildMember.d.ts +7 -7
- package/lib/structures/GuildMember.js +28 -7
- package/lib/structures/GuildRole.d.ts +1 -1
- package/lib/structures/GuildRole.js +2 -2
- package/lib/structures/Interaction.d.ts +11 -9
- package/lib/structures/Interaction.js +33 -12
- package/lib/structures/Message.d.ts +21 -14
- package/lib/structures/Message.js +29 -14
- package/lib/structures/User.d.ts +1 -1
- package/lib/structures/VoiceState.d.ts +4 -0
- package/lib/structures/VoiceState.js +13 -1
- package/lib/structures/Webhook.d.ts +9 -1
- package/lib/structures/Webhook.js +4 -1
- package/lib/structures/channels.d.ts +148 -134
- package/lib/structures/channels.js +27 -26
- package/lib/structures/extra/BitField.d.ts +4 -4
- package/lib/structures/extra/BitField.js +20 -4
- package/lib/structures/extra/DiscordBase.js +1 -1
- package/lib/structures/extra/Permissions.d.ts +2 -4
- package/lib/structures/extra/Permissions.js +1 -17
- package/lib/types/payloads/_interactions/responses.d.ts +2 -2
- package/lib/types/payloads/components.d.ts +4 -4
- package/lib/websocket/SharedTypes.d.ts +4 -4
- package/lib/websocket/constants/index.d.ts +1 -1
- package/lib/websocket/constants/index.js +3 -2
- package/lib/websocket/discord/events/memberUpdate.js +2 -2
- package/lib/websocket/discord/heartbeater.d.ts +1 -0
- package/lib/websocket/discord/heartbeater.js +7 -0
- package/lib/websocket/discord/shard.d.ts +2 -2
- package/lib/websocket/discord/shard.js +15 -13
- package/lib/websocket/discord/sharder.d.ts +8 -7
- package/lib/websocket/discord/sharder.js +25 -5
- package/lib/websocket/discord/shared.d.ts +19 -6
- package/lib/websocket/discord/socket/custom.js +5 -0
- package/lib/websocket/discord/worker.d.ts +1 -0
- package/lib/websocket/discord/worker.js +2 -0
- package/lib/websocket/discord/workermanager.d.ts +25 -11
- package/lib/websocket/discord/workermanager.js +41 -10
- package/package.json +12 -16
package/lib/commands/handler.js
CHANGED
|
@@ -21,15 +21,41 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
21
21
|
this.client = client;
|
|
22
22
|
}
|
|
23
23
|
async reload(resolve) {
|
|
24
|
-
if ((0, common_1.
|
|
24
|
+
if ((0, common_1.isCloudflareWorker)()) {
|
|
25
25
|
throw new common_1.SeyfertError('RELOAD_NOT_SUPPORTED', {
|
|
26
26
|
metadata: { detail: 'Reload in Cloudflare worker is not supported' },
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const command = typeof resolve === 'string' ? this.values.find(x => x.name === resolve) : resolve;
|
|
30
|
+
if (!command?.__filePath)
|
|
31
|
+
return null;
|
|
32
|
+
delete require.cache[command.__filePath];
|
|
33
|
+
const imported = await (0, common_1.magicImport)(command.__filePath).then(x => x.default ?? x);
|
|
34
|
+
const options = this.client.createPluginCommandLoadOptions?.() ?? {};
|
|
35
|
+
const commandInstance = this.onCommand(imported, options.create);
|
|
36
|
+
if (!commandInstance || commandInstance instanceof chat_1.SubCommand)
|
|
37
|
+
return null;
|
|
38
|
+
commandInstance.__filePath = command.__filePath;
|
|
39
|
+
let prepared = this.prepareCommand(commandInstance);
|
|
40
|
+
if (!prepared)
|
|
41
|
+
return null;
|
|
42
|
+
const wrapped = options.transform?.(prepared) ?? prepared;
|
|
43
|
+
if (!wrapped)
|
|
44
|
+
return null;
|
|
45
|
+
if (wrapped !== prepared) {
|
|
46
|
+
wrapped.__filePath ??= command.__filePath;
|
|
47
|
+
prepared = this.prepareCommand(wrapped);
|
|
48
|
+
if (!prepared)
|
|
49
|
+
return null;
|
|
31
50
|
}
|
|
32
|
-
|
|
51
|
+
const index = this.values.indexOf(command);
|
|
52
|
+
if ('handler' in prepared && prepared.handler) {
|
|
53
|
+
this.entryPoint = prepared;
|
|
54
|
+
}
|
|
55
|
+
else if (index >= 0) {
|
|
56
|
+
this.values[index] = prepared;
|
|
57
|
+
}
|
|
58
|
+
return prepared;
|
|
33
59
|
}
|
|
34
60
|
async reloadAll(stopIfFail = true) {
|
|
35
61
|
for (const command of this.values) {
|
|
@@ -65,7 +91,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
65
91
|
}
|
|
66
92
|
return false;
|
|
67
93
|
}
|
|
68
|
-
|
|
94
|
+
shouldUploadChoices(option, cached) {
|
|
69
95
|
const optionChoiceable = option;
|
|
70
96
|
const cachedChoiceable = cached;
|
|
71
97
|
if (!(optionChoiceable.choices?.length && cachedChoiceable.choices?.length))
|
|
@@ -98,7 +124,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
98
124
|
return (option.min_length !== cached.min_length ||
|
|
99
125
|
option.max_length !== cached.max_length ||
|
|
100
126
|
!!option.autocomplete !== !!cached.autocomplete ||
|
|
101
|
-
this.
|
|
127
|
+
this.shouldUploadChoices(option, cached));
|
|
102
128
|
case types_1.ApplicationCommandOptionType.Channel:
|
|
103
129
|
{
|
|
104
130
|
if (option.channel_types?.length !== cached.channel_types?.length)
|
|
@@ -134,7 +160,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
134
160
|
return (option.min_value !== cached.min_value ||
|
|
135
161
|
option.max_value !== cached.max_value ||
|
|
136
162
|
!!option.autocomplete !== !!cached.autocomplete ||
|
|
137
|
-
this.
|
|
163
|
+
this.shouldUploadChoices(option, cached));
|
|
138
164
|
case types_1.ApplicationCommandOptionType.Attachment:
|
|
139
165
|
case types_1.ApplicationCommandOptionType.Boolean:
|
|
140
166
|
case types_1.ApplicationCommandOptionType.Mentionable:
|
|
@@ -221,35 +247,77 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
221
247
|
}
|
|
222
248
|
return false;
|
|
223
249
|
}
|
|
224
|
-
|
|
250
|
+
prepareCommand(commandInstance) {
|
|
251
|
+
if (commandInstance instanceof chat_1.SubCommand)
|
|
252
|
+
return false;
|
|
253
|
+
commandInstance.props ??= this.client.options.commands?.defaults?.props ?? {};
|
|
254
|
+
const isCommand = this.stablishCommandDefaults(commandInstance);
|
|
255
|
+
if (isCommand) {
|
|
256
|
+
for (const option of isCommand.options ?? []) {
|
|
257
|
+
if (option instanceof chat_1.SubCommand)
|
|
258
|
+
this.stablishSubCommandDefaults(isCommand, option);
|
|
259
|
+
}
|
|
260
|
+
this.checkSubCommandsLimit(isCommand);
|
|
261
|
+
}
|
|
262
|
+
else
|
|
263
|
+
this.stablishContextCommandDefaults(commandInstance);
|
|
264
|
+
this.parseLocales(commandInstance);
|
|
265
|
+
return commandInstance;
|
|
266
|
+
}
|
|
267
|
+
checkSubCommandsLimit(command) {
|
|
268
|
+
const counts = {};
|
|
269
|
+
for (const option of command.options ?? []) {
|
|
270
|
+
if (!(option instanceof chat_1.SubCommand))
|
|
271
|
+
continue;
|
|
272
|
+
const group = option.group ?? '';
|
|
273
|
+
counts[group] = (counts[group] ?? 0) + 1;
|
|
274
|
+
}
|
|
275
|
+
for (const group in counts) {
|
|
276
|
+
if (counts[group] > 25) {
|
|
277
|
+
this.logger.warn(`Command "${command.name}"${group ? ` group "${group}"` : ''} has ${counts[group]} subcommands, exceeding Discord's limit of 25.`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
normalizeLoadOptions(options) {
|
|
282
|
+
return typeof options === 'function' ? { transform: options } : (options ?? {});
|
|
283
|
+
}
|
|
284
|
+
set(commands, optionsOrTransform) {
|
|
285
|
+
const options = this.normalizeLoadOptions(optionsOrTransform);
|
|
286
|
+
const added = [];
|
|
225
287
|
this.values ??= [];
|
|
226
288
|
for (const command of commands) {
|
|
227
289
|
let commandInstance;
|
|
228
290
|
try {
|
|
229
|
-
commandInstance = this.onCommand(command);
|
|
291
|
+
commandInstance = this.onCommand(command, options.create);
|
|
230
292
|
if (!commandInstance)
|
|
231
293
|
continue;
|
|
232
294
|
}
|
|
233
295
|
catch (e) {
|
|
234
|
-
this.logger.warn(`${command.name}
|
|
296
|
+
this.logger.warn(`${command.name} isn't a resolvable command`);
|
|
235
297
|
this.logger.error(e);
|
|
236
298
|
continue;
|
|
237
299
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
300
|
+
const prepared = this.prepareCommand(commandInstance);
|
|
301
|
+
if (!prepared)
|
|
302
|
+
continue;
|
|
303
|
+
const wrapped = options.transform?.(prepared) ?? prepared;
|
|
304
|
+
if (!wrapped)
|
|
305
|
+
continue;
|
|
306
|
+
commandInstance = wrapped === prepared ? prepared : this.prepareCommand(wrapped);
|
|
307
|
+
if (!commandInstance)
|
|
308
|
+
continue;
|
|
309
|
+
if ('handler' in commandInstance && commandInstance.handler) {
|
|
310
|
+
this.entryPoint = commandInstance;
|
|
311
|
+
added.push(commandInstance);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.values.push(commandInstance);
|
|
315
|
+
added.push(commandInstance);
|
|
245
316
|
}
|
|
246
|
-
else
|
|
247
|
-
this.stablishContextCommandDefaults(commandInstance);
|
|
248
|
-
this.parseLocales(commandInstance);
|
|
249
|
-
this.values.push(commandInstance);
|
|
250
317
|
}
|
|
318
|
+
return added;
|
|
251
319
|
}
|
|
252
|
-
async load(commandsDir, client) {
|
|
320
|
+
async load(commandsDir, client, options = {}) {
|
|
253
321
|
const result = await this.loadFilesK(await this.getFiles(commandsDir));
|
|
254
322
|
this.values = [];
|
|
255
323
|
for (const { commands, file } of result.map(x => ({ commands: this.onFile(x.file), file: x }))) {
|
|
@@ -258,7 +326,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
258
326
|
for (const command of commands) {
|
|
259
327
|
let commandInstance;
|
|
260
328
|
try {
|
|
261
|
-
commandInstance = this.onCommand(command);
|
|
329
|
+
commandInstance = this.onCommand(command, options.create);
|
|
262
330
|
if (!commandInstance)
|
|
263
331
|
continue;
|
|
264
332
|
}
|
|
@@ -288,9 +356,10 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
288
356
|
continue;
|
|
289
357
|
}
|
|
290
358
|
try {
|
|
359
|
+
const relativePath = option.split(process.cwd()).slice(1).join(process.cwd());
|
|
291
360
|
const fileSubCommands = this.onFile(result.find(x => x.path === option).file);
|
|
292
361
|
if (!fileSubCommands) {
|
|
293
|
-
this.logger.warn(`
|
|
362
|
+
this.logger.warn(`Command "${commandInstance.name}": no default export found in "${relativePath}", ignoring it as a SubCommand.`);
|
|
294
363
|
continue;
|
|
295
364
|
}
|
|
296
365
|
for (const fileSubCommand of fileSubCommands) {
|
|
@@ -300,7 +369,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
300
369
|
commandInstance.options.push(subCommand);
|
|
301
370
|
}
|
|
302
371
|
else {
|
|
303
|
-
this.logger.warn(
|
|
372
|
+
this.logger.warn(`Command "${commandInstance.name}": expected a SubCommand from "${relativePath}", got (${subCommand}); ignoring it.`, subCommand);
|
|
304
373
|
}
|
|
305
374
|
}
|
|
306
375
|
}
|
|
@@ -316,6 +385,26 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
316
385
|
}
|
|
317
386
|
this.stablishContextCommandDefaults(commandInstance);
|
|
318
387
|
this.parseLocales(commandInstance);
|
|
388
|
+
const wrapped = options.transform?.(commandInstance) ?? commandInstance;
|
|
389
|
+
if (!wrapped)
|
|
390
|
+
continue;
|
|
391
|
+
if (wrapped !== commandInstance) {
|
|
392
|
+
commandInstance = wrapped;
|
|
393
|
+
commandInstance.__filePath ??= file.path;
|
|
394
|
+
commandInstance.props ??= client.options.commands?.defaults?.props ?? {};
|
|
395
|
+
const wrappedCommand = this.stablishCommandDefaults(commandInstance);
|
|
396
|
+
if (wrappedCommand) {
|
|
397
|
+
commandInstance = wrappedCommand;
|
|
398
|
+
for (const option of commandInstance.options ?? []) {
|
|
399
|
+
if (option instanceof chat_1.SubCommand)
|
|
400
|
+
this.stablishSubCommandDefaults(commandInstance, option);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
this.stablishContextCommandDefaults(commandInstance);
|
|
404
|
+
this.parseLocales(commandInstance);
|
|
405
|
+
}
|
|
406
|
+
if (commandInstance instanceof chat_1.Command)
|
|
407
|
+
this.checkSubCommandsLimit(commandInstance);
|
|
319
408
|
if ('handler' in commandInstance && commandInstance.handler) {
|
|
320
409
|
this.entryPoint = commandInstance;
|
|
321
410
|
}
|
|
@@ -338,7 +427,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
338
427
|
this.parseSubCommandLocales(option);
|
|
339
428
|
continue;
|
|
340
429
|
}
|
|
341
|
-
this.parseCommandOptionLocales(option);
|
|
430
|
+
this.parseCommandOptionLocales(option, command.name);
|
|
342
431
|
}
|
|
343
432
|
}
|
|
344
433
|
if (command instanceof chat_1.SubCommand) {
|
|
@@ -346,62 +435,67 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
346
435
|
}
|
|
347
436
|
return command;
|
|
348
437
|
}
|
|
438
|
+
getLocales(locale) {
|
|
439
|
+
const locales = [...(this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [])];
|
|
440
|
+
if (Object.values(types_1.Locale).includes(locale) && !locales.includes(locale)) {
|
|
441
|
+
locales.push(locale);
|
|
442
|
+
}
|
|
443
|
+
return locales;
|
|
444
|
+
}
|
|
445
|
+
getLocaleKey(locale, key, context) {
|
|
446
|
+
const value = this.client.langs.getKey(locale, key);
|
|
447
|
+
if (typeof value === 'undefined') {
|
|
448
|
+
this.logger.warn(`Locale key "${key}" resolved to nothing for ${context} in locale "${locale}".`);
|
|
449
|
+
}
|
|
450
|
+
return value;
|
|
451
|
+
}
|
|
349
452
|
parseGlobalLocales(command) {
|
|
350
453
|
if (command.__t) {
|
|
351
454
|
command.name_localizations ??= {};
|
|
352
455
|
command.description_localizations ??= {};
|
|
353
456
|
for (const locale of Object.keys(this.client.langs.values)) {
|
|
354
|
-
const locales = this.
|
|
355
|
-
if (Object.values(types_1.Locale).includes(locale))
|
|
356
|
-
locales.push(locale);
|
|
457
|
+
const locales = this.getLocales(locale);
|
|
357
458
|
if (command.__t.name) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
459
|
+
const valueName = this.getLocaleKey(locale, command.__t.name, `command "${command.name}" name`);
|
|
460
|
+
if (valueName)
|
|
461
|
+
for (const i of locales)
|
|
361
462
|
command.name_localizations[i] = valueName;
|
|
362
|
-
}
|
|
363
463
|
}
|
|
364
464
|
if (command.__t.description) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
465
|
+
const valueKey = this.getLocaleKey(locale, command.__t.description, `command "${command.name}" description`);
|
|
466
|
+
if (valueKey)
|
|
467
|
+
for (const i of locales)
|
|
368
468
|
command.description_localizations[i] = valueKey;
|
|
369
|
-
}
|
|
370
469
|
}
|
|
371
470
|
}
|
|
372
471
|
}
|
|
373
472
|
}
|
|
374
|
-
parseCommandOptionLocales(option) {
|
|
473
|
+
parseCommandOptionLocales(option, commandName = 'unknown') {
|
|
375
474
|
option.name_localizations ??= {};
|
|
376
475
|
option.description_localizations ??= {};
|
|
377
476
|
for (const locale of Object.keys(this.client.langs.values)) {
|
|
378
|
-
const locales = this.
|
|
379
|
-
if (Object.values(types_1.Locale).includes(locale))
|
|
380
|
-
locales.push(locale);
|
|
477
|
+
const locales = this.getLocales(locale);
|
|
381
478
|
if (option.locales?.name) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
479
|
+
const valueName = this.getLocaleKey(locale, option.locales.name, `command "${commandName}" option "${option.name}" name`);
|
|
480
|
+
if (valueName)
|
|
481
|
+
for (const i of locales)
|
|
385
482
|
option.name_localizations[i] = valueName;
|
|
386
|
-
}
|
|
387
483
|
}
|
|
388
484
|
if (option.locales?.description) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
485
|
+
const valueKey = this.getLocaleKey(locale, option.locales.description, `command "${commandName}" option "${option.name}" description`);
|
|
486
|
+
if (valueKey)
|
|
487
|
+
for (const i of locales)
|
|
392
488
|
option.description_localizations[i] = valueKey;
|
|
393
|
-
}
|
|
394
489
|
}
|
|
395
490
|
if ('choices' in option && option.choices?.length) {
|
|
396
491
|
for (const c of option.choices) {
|
|
397
492
|
c.name_localizations ??= {};
|
|
398
493
|
if (!c.locales)
|
|
399
494
|
continue;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
495
|
+
const valueKey = this.getLocaleKey(locale, c.locales, `command "${commandName}" option "${option.name}" choice "${c.name}"`);
|
|
496
|
+
if (valueKey)
|
|
497
|
+
for (const i of locales)
|
|
403
498
|
c.name_localizations[i] = valueKey;
|
|
404
|
-
}
|
|
405
499
|
}
|
|
406
500
|
}
|
|
407
501
|
}
|
|
@@ -409,9 +503,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
409
503
|
parseCommandLocales(command) {
|
|
410
504
|
command.groups ??= {};
|
|
411
505
|
for (const locale of Object.keys(this.client.langs.values)) {
|
|
412
|
-
const locales = this.
|
|
413
|
-
if (Object.values(types_1.Locale).includes(locale))
|
|
414
|
-
locales.push(locale);
|
|
506
|
+
const locales = this.getLocales(locale);
|
|
415
507
|
for (const group in command.__tGroups) {
|
|
416
508
|
command.groups[group] ??= {
|
|
417
509
|
defaultDescription: command.__tGroups[group].defaultDescription,
|
|
@@ -419,20 +511,16 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
419
511
|
name: [],
|
|
420
512
|
};
|
|
421
513
|
if (command.__tGroups[group].name) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
514
|
+
const valueName = this.getLocaleKey(locale, command.__tGroups[group].name, `command "${command.name}" group "${group}" name`);
|
|
515
|
+
if (valueName)
|
|
516
|
+
for (const i of locales)
|
|
425
517
|
command.groups[group].name.push([i, valueName]);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
518
|
}
|
|
429
519
|
if (command.__tGroups[group].description) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
520
|
+
const valueKey = this.getLocaleKey(locale, command.__tGroups[group].description, `command "${command.name}" group "${group}" description`);
|
|
521
|
+
if (valueKey)
|
|
522
|
+
for (const i of locales)
|
|
433
523
|
command.groups[group].description.push([i, valueKey]);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
524
|
}
|
|
437
525
|
}
|
|
438
526
|
}
|
|
@@ -443,7 +531,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
443
531
|
parseSubCommandLocales(command) {
|
|
444
532
|
this.parseGlobalLocales(command);
|
|
445
533
|
for (const i of command.options ?? []) {
|
|
446
|
-
this.parseCommandOptionLocales(i);
|
|
534
|
+
this.parseCommandOptionLocales(i, command.name);
|
|
447
535
|
}
|
|
448
536
|
return command;
|
|
449
537
|
}
|
|
@@ -527,8 +615,8 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
527
615
|
onFile(file) {
|
|
528
616
|
return file.default ? [file.default] : undefined;
|
|
529
617
|
}
|
|
530
|
-
onCommand(file) {
|
|
531
|
-
return new file();
|
|
618
|
+
onCommand(file, create) {
|
|
619
|
+
return typeof file === 'function' ? (create?.(file, () => new file()) ?? new file()) : file;
|
|
532
620
|
}
|
|
533
621
|
onSubCommand(file) {
|
|
534
622
|
return new file();
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Attachment } from '../builders';
|
|
2
2
|
import { type GuildMemberStructure, type GuildRoleStructure, type InteractionGuildMemberStructure, type UserStructure } from '../client/transformers';
|
|
3
|
-
import { type
|
|
3
|
+
import { type MakePresent } from '../common';
|
|
4
4
|
import { type AllChannels } from '../structures';
|
|
5
5
|
import { type APIApplicationCommandInteractionDataOption, type APIAttachment, type APIGuildMember, type APIInteractionDataResolvedChannel, type APIInteractionGuildMember, type APIRole, type APIUser, ApplicationCommandOptionType } from '../types';
|
|
6
6
|
import type { Command, CommandAutocompleteOption, SubCommand } from './applications/chat';
|
|
@@ -49,7 +49,7 @@ export interface OptionResolved {
|
|
|
49
49
|
role?: GuildRoleStructure;
|
|
50
50
|
focused?: boolean;
|
|
51
51
|
}
|
|
52
|
-
export type OptionResolvedWithValue =
|
|
52
|
+
export type OptionResolvedWithValue = MakePresent<Pick<OptionResolved, 'name' | 'value' | 'focused'>, 'value'> & {
|
|
53
53
|
type: ApplicationCommandOptionType.Boolean | ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.String;
|
|
54
54
|
};
|
|
55
55
|
export type OptionResolvedWithProp = Exclude<OptionResolved, {
|
package/lib/common/it/colors.js
CHANGED
|
@@ -66,12 +66,22 @@ function getColorEnabled() {
|
|
|
66
66
|
* @param open
|
|
67
67
|
* @param close
|
|
68
68
|
*/
|
|
69
|
+
const codeCache = new Map();
|
|
69
70
|
function code(open, close) {
|
|
70
|
-
|
|
71
|
+
const createCode = () => ({
|
|
71
72
|
open: `\x1b[${open.join(';')}m`,
|
|
72
73
|
close: `\x1b[${close}m`,
|
|
73
74
|
regexp: new RegExp(`\\x1b\\[${close}m`, 'g'),
|
|
74
|
-
};
|
|
75
|
+
});
|
|
76
|
+
if ((open[0] === 38 || open[0] === 48) && open[1] === 2)
|
|
77
|
+
return createCode();
|
|
78
|
+
const key = `${open.join(';')};${close}`;
|
|
79
|
+
let cached = codeCache.get(key);
|
|
80
|
+
if (!cached) {
|
|
81
|
+
cached = createCode();
|
|
82
|
+
codeCache.set(key, cached);
|
|
83
|
+
}
|
|
84
|
+
return cached;
|
|
75
85
|
}
|
|
76
86
|
/**
|
|
77
87
|
* Applies color and background based on color code and its associated text
|
package/lib/common/it/error.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ export declare class SeyfertError extends Error {
|
|
|
31
31
|
* Optional contextual data attached to the error.
|
|
32
32
|
*/
|
|
33
33
|
metadata?: Record<string, unknown>;
|
|
34
|
+
static is(error: unknown): error is SeyfertError;
|
|
35
|
+
static is<C extends SeyfertErrorCode>(error: unknown, code: C): error is SeyfertError & {
|
|
36
|
+
code: C;
|
|
37
|
+
};
|
|
34
38
|
/**
|
|
35
39
|
* Creates a SeyfertError instance.
|
|
36
40
|
*
|
|
@@ -66,6 +70,7 @@ export declare const SeyfertErrorMessages: {
|
|
|
66
70
|
INVALID_TOKEN: string;
|
|
67
71
|
FUNCTION_NOT_IMPLEMENTED: string;
|
|
68
72
|
NO_SEYFERT_CONFIG: string;
|
|
73
|
+
SEYFERT_CONFIG_LOAD_ERROR: string;
|
|
69
74
|
BAD_OPTION: string;
|
|
70
75
|
INVALID_EMOJI: string;
|
|
71
76
|
EMOJI_NOT_RESOLVABLE: string;
|
|
@@ -77,16 +82,20 @@ export declare const SeyfertErrorMessages: {
|
|
|
77
82
|
UNDEFINED_LOCALE: string;
|
|
78
83
|
INTERACTION_ALREADY_REPLIED: string;
|
|
79
84
|
CANNOT_USE_REPLY: string;
|
|
85
|
+
CANNOT_USE_MODAL: string;
|
|
80
86
|
RELOAD_NOT_SUPPORTED: string;
|
|
81
87
|
API_WORKER_PROXY_PARENT_REQUIRED: string;
|
|
82
88
|
WORKER_TIMEOUT: string;
|
|
83
89
|
WORKER_THREADS_REQUIRED: string;
|
|
90
|
+
PLUGIN_FAILED: string;
|
|
91
|
+
PLUGIN_TEARDOWN_FAILED: string;
|
|
84
92
|
WORKER_AND_SHARD_ID_REQUIRED: string;
|
|
85
93
|
WORKER_NOT_FOUND: string;
|
|
86
94
|
INVALID_SHARD_ID: string;
|
|
87
95
|
INVALID_WORKER_REQUEST: string;
|
|
88
96
|
CANNOT_OVERRIDE_EXISTING_SHARD: string;
|
|
89
97
|
INVALID_SEC_WEBSOCKET_ACCEPT_HEADER: string;
|
|
98
|
+
REQUEST_GUILD_MEMBERS_TIMEOUT: string;
|
|
90
99
|
CACHE_TIMEOUT: string;
|
|
91
100
|
CACHE_USERS_DISABLED: string;
|
|
92
101
|
CACHE_MEMBERS_DISABLED: string;
|
package/lib/common/it/error.js
CHANGED
|
@@ -35,6 +35,9 @@ class SeyfertError extends Error {
|
|
|
35
35
|
* Optional contextual data attached to the error.
|
|
36
36
|
*/
|
|
37
37
|
metadata;
|
|
38
|
+
static is(error, code) {
|
|
39
|
+
return error instanceof SeyfertError && (code === undefined || error.code === code);
|
|
40
|
+
}
|
|
38
41
|
/**
|
|
39
42
|
* Creates a SeyfertError instance.
|
|
40
43
|
*
|
|
@@ -79,6 +82,7 @@ exports.SeyfertErrorMessages = {
|
|
|
79
82
|
INVALID_TOKEN: 'Invalid token.',
|
|
80
83
|
FUNCTION_NOT_IMPLEMENTED: 'Function not implemented.',
|
|
81
84
|
NO_SEYFERT_CONFIG: 'No seyfert.config file found.',
|
|
85
|
+
SEYFERT_CONFIG_LOAD_ERROR: 'Failed to load seyfert.config file.',
|
|
82
86
|
BAD_OPTION: 'Bad option.',
|
|
83
87
|
INVALID_EMOJI: 'Invalid emoji.',
|
|
84
88
|
EMOJI_NOT_RESOLVABLE: 'Emoji not resolvable.',
|
|
@@ -90,16 +94,20 @@ exports.SeyfertErrorMessages = {
|
|
|
90
94
|
UNDEFINED_LOCALE: 'Undefined locale.',
|
|
91
95
|
INTERACTION_ALREADY_REPLIED: 'Interaction already replied.',
|
|
92
96
|
CANNOT_USE_REPLY: 'Cannot use reply in this interaction.',
|
|
97
|
+
CANNOT_USE_MODAL: 'Cannot use modal without an interaction.',
|
|
93
98
|
RELOAD_NOT_SUPPORTED: 'Reload in Cloudflare worker is not supported.',
|
|
94
99
|
API_WORKER_PROXY_PARENT_REQUIRED: 'Cannot use workerProxy without a parent.',
|
|
95
100
|
WORKER_TIMEOUT: 'Worker request timed out.',
|
|
96
101
|
WORKER_THREADS_REQUIRED: 'worker_threads is required for this operation.',
|
|
102
|
+
PLUGIN_FAILED: 'Plugin failed.',
|
|
103
|
+
PLUGIN_TEARDOWN_FAILED: 'Plugin teardown failed.',
|
|
97
104
|
WORKER_AND_SHARD_ID_REQUIRED: 'workerId and shardId are required.',
|
|
98
105
|
WORKER_NOT_FOUND: 'Worker not found.',
|
|
99
106
|
INVALID_SHARD_ID: 'Invalid shardId.',
|
|
100
107
|
INVALID_WORKER_REQUEST: 'Invalid request from unavailable worker.',
|
|
101
108
|
CANNOT_OVERRIDE_EXISTING_SHARD: 'Cannot override existing shard.',
|
|
102
109
|
INVALID_SEC_WEBSOCKET_ACCEPT_HEADER: 'Invalid sec-websocket-accept header.',
|
|
110
|
+
REQUEST_GUILD_MEMBERS_TIMEOUT: 'Request guild members timed out, 30s without receiving a chunk.',
|
|
103
111
|
CACHE_TIMEOUT: 'Cache request timed out.',
|
|
104
112
|
CACHE_USERS_DISABLED: 'Users cache is disabled.',
|
|
105
113
|
CACHE_MEMBERS_DISABLED: 'Members cache is disabled.',
|
|
@@ -11,7 +11,7 @@ export type OAuth2URLOptions = {
|
|
|
11
11
|
/**
|
|
12
12
|
* Permissions to be granted to the application.
|
|
13
13
|
*/
|
|
14
|
-
permissions
|
|
14
|
+
permissions?: BitFieldResolvable<typeof PermissionFlagsBits>;
|
|
15
15
|
/**
|
|
16
16
|
* Whether guild select must be disabled in oauth2 interface.
|
|
17
17
|
*/
|
|
@@ -87,11 +87,15 @@ export declare enum TimestampStyle {
|
|
|
87
87
|
/**
|
|
88
88
|
* Represents a message link.
|
|
89
89
|
*/
|
|
90
|
-
type MessageLink = `https://discord.com/channels/${string}/${string}/${string}`;
|
|
90
|
+
export type MessageLink = `https://discord.com/channels/${string}/${string}/${string}`;
|
|
91
|
+
/**
|
|
92
|
+
* Represents a channel link.
|
|
93
|
+
*/
|
|
94
|
+
export type ChannelLink = `https://discord.com/channels/${string}/${string}`;
|
|
91
95
|
/**
|
|
92
96
|
* Represents a timestamp.
|
|
93
97
|
*/
|
|
94
|
-
type Timestamp = `<t:${number}:${TimestampStyle}>`;
|
|
98
|
+
export type Timestamp = `<t:${number}:${TimestampStyle}>`;
|
|
95
99
|
/**
|
|
96
100
|
* Represents a formatter utility for formatting content.
|
|
97
101
|
*/
|
|
@@ -151,13 +155,13 @@ export declare const Formatter: {
|
|
|
151
155
|
* @param content The content to format.
|
|
152
156
|
* @returns The formatted content.
|
|
153
157
|
*/
|
|
154
|
-
blockQuote(content: string): string
|
|
158
|
+
blockQuote(content: string): `>>> ${string}`;
|
|
155
159
|
/**
|
|
156
160
|
* Formats content into a quote.
|
|
157
161
|
* @param content The content to format.
|
|
158
162
|
* @returns The formatted content.
|
|
159
163
|
*/
|
|
160
|
-
quote(content: string): string
|
|
164
|
+
quote(content: string): `> ${string}`;
|
|
161
165
|
/**
|
|
162
166
|
* Formats a message link.
|
|
163
167
|
* @param guildId The ID of the guild.
|
|
@@ -182,11 +186,11 @@ export declare const Formatter: {
|
|
|
182
186
|
list(items: string[], ordered?: boolean): string;
|
|
183
187
|
/**
|
|
184
188
|
* Formats the given timestamp into discord unix timestamp format.
|
|
185
|
-
* @param timestamp The timestamp to format.
|
|
186
|
-
* @param style The style of the timestamp. Defaults to '
|
|
189
|
+
* @param timestamp The Date or unix millisecond timestamp to format.
|
|
190
|
+
* @param style The style of the timestamp. Defaults to 'R'.
|
|
187
191
|
* @returns The formatted timestamp.
|
|
188
192
|
*/
|
|
189
|
-
timestamp(timestamp: Date, style?: TimestampStyle): Timestamp;
|
|
193
|
+
timestamp(timestamp: Date | number, style?: TimestampStyle): Timestamp;
|
|
190
194
|
/**
|
|
191
195
|
* Formats a user mention.
|
|
192
196
|
* @param userId The ID of the user to mention.
|
|
@@ -211,14 +215,14 @@ export declare const Formatter: {
|
|
|
211
215
|
* @param animated Whether the emoji is animated. Defaults to false.
|
|
212
216
|
* @returns The formatted emoji.
|
|
213
217
|
*/
|
|
214
|
-
emojiMention(emojiId: string, name: string | null, animated?: boolean): string
|
|
218
|
+
emojiMention(emojiId: string, name: string | null, animated?: boolean): `<${"a" | ""}:${string}:${string}>`;
|
|
215
219
|
/**
|
|
216
220
|
* Formats a channel link.
|
|
217
221
|
* @param channelId The ID of the channel.
|
|
218
222
|
* @param guildId The ID of the guild. Defaults to '@me'.
|
|
219
223
|
* @returns The formatted channel link.
|
|
220
224
|
*/
|
|
221
|
-
channelLink(channelId: string, guildId?: string):
|
|
225
|
+
channelLink(channelId: string, guildId?: string): ChannelLink;
|
|
222
226
|
/**
|
|
223
227
|
* Forms a oauth2 invite link for the bot.
|
|
224
228
|
* @param applicationId The ID of the application.
|
|
@@ -229,4 +233,3 @@ export declare const Formatter: {
|
|
|
229
233
|
*/
|
|
230
234
|
generateOAuth2URL(applicationId: string, { scopes, permissions, disableGuildSelect }: OAuth2URLOptions): string;
|
|
231
235
|
};
|
|
232
|
-
export {};
|
|
@@ -191,12 +191,13 @@ exports.Formatter = {
|
|
|
191
191
|
},
|
|
192
192
|
/**
|
|
193
193
|
* Formats the given timestamp into discord unix timestamp format.
|
|
194
|
-
* @param timestamp The timestamp to format.
|
|
195
|
-
* @param style The style of the timestamp. Defaults to '
|
|
194
|
+
* @param timestamp The Date or unix millisecond timestamp to format.
|
|
195
|
+
* @param style The style of the timestamp. Defaults to 'R'.
|
|
196
196
|
* @returns The formatted timestamp.
|
|
197
197
|
*/
|
|
198
198
|
timestamp(timestamp, style = TimestampStyle.RelativeTime) {
|
|
199
|
-
|
|
199
|
+
const timestampSeconds = typeof timestamp === 'number' ? Math.floor(timestamp / 1000) : Math.floor(timestamp.getTime() / 1000);
|
|
200
|
+
return `<t:${timestampSeconds}:${style}>`;
|
|
200
201
|
},
|
|
201
202
|
/**
|
|
202
203
|
* Formats a user mention.
|
|
@@ -30,6 +30,7 @@ export declare class Logger {
|
|
|
30
30
|
/**
|
|
31
31
|
* The custom callback function for logging.
|
|
32
32
|
*/
|
|
33
|
+
private static __memoryCache;
|
|
33
34
|
private static __callback;
|
|
34
35
|
/**
|
|
35
36
|
* Allows customization of the logging behavior by providing a custom callback function.
|
|
@@ -38,8 +39,13 @@ export declare class Logger {
|
|
|
38
39
|
* Logger.customize((logger, level, args) => {
|
|
39
40
|
* // Custom logging implementation
|
|
40
41
|
* });
|
|
42
|
+
* @returns A disposer that restores the previous callback (no-op if a newer one replaced it).
|
|
41
43
|
*/
|
|
42
|
-
static customize(cb: CustomizeLoggerCallback): void;
|
|
44
|
+
static customize(cb: CustomizeLoggerCallback): () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the current logging callback, so a customizer can chain the previous one.
|
|
47
|
+
*/
|
|
48
|
+
static getCustomizer(): CustomizeLoggerCallback;
|
|
43
49
|
/**
|
|
44
50
|
* Customizes the logging filename by providing a callback function.
|
|
45
51
|
* The callback receives the logger instance and should return the desired filename.
|