diskernel 0.1.22 → 0.1.24
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/dist/core/client.d.ts +1 -1
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +2 -4
- package/dist/core/command.d.ts +1 -1
- package/dist/core/command.d.ts.map +1 -1
- package/dist/core/command.js +41 -22
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +2 -9
- package/dist/core/error.d.ts +1 -1
- package/dist/core/error.d.ts.map +1 -1
- package/dist/core/error.js +1 -1
- package/dist/core/event.d.ts +1 -1
- package/dist/core/event.d.ts.map +1 -1
- package/dist/core/event.js +1 -1
- package/dist/core/logger.d.ts +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/types/command.d.ts.map +1 -1
- package/dist/types/command.js +0 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -1
- package/package.json +1 -1
package/dist/core/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAMpC,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAMpC,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAWjD,qBAAa,IAAK,SAAQ,IAAI;IAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAiC;IAEtD,WAAkB,MAAM,IAAI,MAAM,GAAG,SAAS,CAM7C;WAEmB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;WAsD5B,IAAI,IAAI,IAAI;CAS3B"}
|
package/dist/core/client.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getCustomCoreLogger, Log } from "./logger.js";
|
|
|
4
4
|
import { ErrorHandler } from "./error.js";
|
|
5
5
|
import { Command } from "./command.js";
|
|
6
6
|
import { Event } from "./event.js";
|
|
7
|
-
import { Core as core } from "
|
|
7
|
+
import { Core as core } from "../types/index.js";
|
|
8
8
|
class DiskernelError extends Error {
|
|
9
9
|
constructor(message, options) {
|
|
10
10
|
super(message, options);
|
|
@@ -39,9 +39,7 @@ export class Core extends core {
|
|
|
39
39
|
});
|
|
40
40
|
Logger.info("▶ Logging in to Discord...");
|
|
41
41
|
Logger.trace(`Using token: ${Config.get("TOKEN").replace(/.(?=.{4})/g, "*")}`);
|
|
42
|
-
await this.client
|
|
43
|
-
.login(Config.get("TOKEN"))
|
|
44
|
-
.catch((e) => {
|
|
42
|
+
await this.client.login(Config.get("TOKEN")).catch((e) => {
|
|
45
43
|
Logger.error("❌ Failed to login to Discord.");
|
|
46
44
|
ErrorHandler.fatal("Failed to login to Discord", e);
|
|
47
45
|
});
|
package/dist/core/command.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/core/command.ts"],"names":[],"mappings":"AAqBA,OAAO,EAML,OAAO,IAAI,OAAO,EAGnB,MAAM,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/core/command.ts"],"names":[],"mappings":"AAqBA,OAAO,EAML,OAAO,IAAI,OAAO,EAGnB,MAAM,mBAAmB,CAAC;AAI3B,qBAAa,OAAQ,SAAQ,OAAO;IAClC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAC5C,OAAO,CAAC,MAAM,CAAC,OAAO,CAGlB;IACJ,OAAO,CAAC,MAAM,CAAC,WAAW,CAIjB;IACT,OAAO,CAAC,MAAM,CAAC,QAAQ,CAGnB;WAEgB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;mBAmC1B,kBAAkB;IA0GvC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAyDlC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAcjC,OAAO,CAAC,MAAM,CAAC,aAAa;mBA8EP,mBAAmB;mBAqBnB,gBAAgB;IA0CrC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAkC/B,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA6BrC,OAAO,CAAC,MAAM,CAAC,gBAAgB;mBA6BV,oBAAoB;mBA6BpB,qBAAqB;mBA2BrB,eAAe;mBA6Bf,cAAc;CA4HpC"}
|
package/dist/core/command.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { ApplicationCommandType, AutocompleteInteraction, ButtonInteraction, ChatInputCommandInteraction,
|
|
3
|
+
import { ApplicationCommandType, AutocompleteInteraction, ButtonInteraction, ChatInputCommandInteraction, ContextMenuCommandBuilder, EmbedBuilder, ModalSubmitInteraction, SlashCommandBuilder, SlashCommandSubcommandBuilder, StringSelectMenuInteraction, } from "discord.js";
|
|
4
4
|
import { Core } from "./client.js";
|
|
5
5
|
import { Config } from "./config.js";
|
|
6
6
|
import { getCustomCoreLogger } from "./logger.js";
|
|
7
|
-
import { SlashCommandT, Command as command, BaseAction, BaseCommand } from "
|
|
7
|
+
import { SlashCommandT, Command as command, BaseAction, BaseCommand, } from "../types/index.js";
|
|
8
8
|
const Logger = getCustomCoreLogger("commands");
|
|
9
9
|
export class Command extends command {
|
|
10
10
|
static client;
|
|
@@ -39,7 +39,7 @@ export class Command extends command {
|
|
|
39
39
|
})();
|
|
40
40
|
if (commands)
|
|
41
41
|
await this.registerWithGuildID(guild.id, commands.guild);
|
|
42
|
-
Logger.info(
|
|
42
|
+
Logger.info("✅ Register commands finished successfully.");
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
static async loadCommandFromDir(dir) {
|
|
@@ -131,39 +131,38 @@ export class Command extends command {
|
|
|
131
131
|
static buildCommandOptions(option, command) {
|
|
132
132
|
switch (option.type) {
|
|
133
133
|
case "string":
|
|
134
|
-
command.addStringOption((
|
|
134
|
+
command.addStringOption((optionBuilder) => optionBuilder
|
|
135
135
|
.setName(option.name)
|
|
136
136
|
.setDescription(option.description)
|
|
137
137
|
.setRequired(option.required)
|
|
138
|
-
.addChoices(option.choices ?? []));
|
|
138
|
+
.addChoices(...(option.choices ?? [])));
|
|
139
139
|
break;
|
|
140
140
|
case "integer":
|
|
141
|
-
command.addIntegerOption((
|
|
141
|
+
command.addIntegerOption((optionBuilder) => optionBuilder
|
|
142
142
|
.setName(option.name)
|
|
143
143
|
.setDescription(option.description)
|
|
144
|
-
.setRequired(option.required)
|
|
145
|
-
.addChoices(option.choices ?? []));
|
|
144
|
+
.setRequired(option.required));
|
|
146
145
|
break;
|
|
147
146
|
case "boolean":
|
|
148
|
-
command.addBooleanOption((
|
|
147
|
+
command.addBooleanOption((optionBuilder) => optionBuilder
|
|
149
148
|
.setName(option.name)
|
|
150
149
|
.setDescription(option.description)
|
|
151
150
|
.setRequired(option.required));
|
|
152
151
|
break;
|
|
153
152
|
case "channel":
|
|
154
|
-
command.addChannelOption((
|
|
153
|
+
command.addChannelOption((optionBuilder) => optionBuilder
|
|
155
154
|
.setName(option.name)
|
|
156
155
|
.setDescription(option.description)
|
|
157
156
|
.setRequired(option.required));
|
|
158
157
|
break;
|
|
159
158
|
case "role":
|
|
160
|
-
command.addRoleOption((
|
|
159
|
+
command.addRoleOption((optionBuilder) => optionBuilder
|
|
161
160
|
.setName(option.name)
|
|
162
161
|
.setDescription(option.description)
|
|
163
162
|
.setRequired(option.required));
|
|
164
163
|
break;
|
|
165
164
|
case "user":
|
|
166
|
-
command.addUserOption((
|
|
165
|
+
command.addUserOption((optionBuilder) => optionBuilder
|
|
167
166
|
.setName(option.name)
|
|
168
167
|
.setDescription(option.description)
|
|
169
168
|
.setRequired(option.required));
|
|
@@ -183,6 +182,7 @@ export class Command extends command {
|
|
|
183
182
|
const commands = [];
|
|
184
183
|
const globalCommands = [];
|
|
185
184
|
for (const command of this.commands) {
|
|
185
|
+
Logger.debug("Building command: {name}", { name: command.name });
|
|
186
186
|
if (command.type === "slash" && !command.parent) {
|
|
187
187
|
const slashCommand = new SlashCommandBuilder()
|
|
188
188
|
.setName(command.name)
|
|
@@ -208,9 +208,14 @@ export class Command extends command {
|
|
|
208
208
|
this.buildCommandOptions(option, subCommand);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
this.subCommands.push({
|
|
211
|
+
this.subCommands.push({
|
|
212
|
+
parent: command.parent,
|
|
213
|
+
command: subCommand,
|
|
214
|
+
isGlobal: command.global,
|
|
215
|
+
});
|
|
212
216
|
}
|
|
213
|
-
else if (command.type === "userContextMenu" ||
|
|
217
|
+
else if (command.type === "userContextMenu" ||
|
|
218
|
+
command.type === "messageContextMenu") {
|
|
214
219
|
const contextMenuCommand = new ContextMenuCommandBuilder()
|
|
215
220
|
.setName(command.name)
|
|
216
221
|
.setType(command.type === "userContextMenu"
|
|
@@ -228,14 +233,16 @@ export class Command extends command {
|
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
235
|
this.subCommands.forEach((v) => {
|
|
231
|
-
const slashCommand = commands.find((c) => c.name === v.parent) ??
|
|
236
|
+
const slashCommand = commands.find((c) => c.name === v.parent) ??
|
|
237
|
+
globalCommands.find((c) => c.name === v.parent) ??
|
|
238
|
+
undefined;
|
|
232
239
|
if (slashCommand instanceof SlashCommandBuilder) {
|
|
233
240
|
slashCommand.addSubcommand(v.command);
|
|
234
241
|
}
|
|
235
242
|
});
|
|
236
243
|
return {
|
|
237
244
|
guild: commands.map((c) => c.toJSON()),
|
|
238
|
-
global: globalCommands.map(c => c.toJSON())
|
|
245
|
+
global: globalCommands.map((c) => c.toJSON()),
|
|
239
246
|
};
|
|
240
247
|
}
|
|
241
248
|
static async registerWithGuildID(guildID, commands) {
|
|
@@ -314,7 +321,8 @@ export class Command extends command {
|
|
|
314
321
|
interaction instanceof ModalSubmitInteraction
|
|
315
322
|
? interaction.customId
|
|
316
323
|
: interaction.commandName;
|
|
317
|
-
const command = this.commands.find((c) => c.name === interactionName) ||
|
|
324
|
+
const command = this.commands.find((c) => c.name === interactionName) ||
|
|
325
|
+
this.actions.get(interactionName);
|
|
318
326
|
if (!command)
|
|
319
327
|
return false;
|
|
320
328
|
if (!command.isAdminOnly)
|
|
@@ -331,7 +339,8 @@ export class Command extends command {
|
|
|
331
339
|
interaction instanceof ModalSubmitInteraction
|
|
332
340
|
? interaction.customId
|
|
333
341
|
: interaction.commandName;
|
|
334
|
-
const command = this.commands.find((c) => c.name === interactionName) ||
|
|
342
|
+
const command = this.commands.find((c) => c.name === interactionName) ||
|
|
343
|
+
this.actions.get(interactionName);
|
|
335
344
|
if (!command)
|
|
336
345
|
return false;
|
|
337
346
|
if (!command.isDevOnly)
|
|
@@ -394,7 +403,9 @@ export class Command extends command {
|
|
|
394
403
|
? interaction.customId
|
|
395
404
|
: interaction.commandName;
|
|
396
405
|
Logger.debug(`Triggered command-interaction: ${interactionName} for ${interaction.user.id}(${interaction.user.globalName})`);
|
|
397
|
-
const command = this.commands.find((c) => c.name === interactionName) ||
|
|
406
|
+
const command = this.commands.find((c) => c.name === interactionName) ||
|
|
407
|
+
this.actions.get(interactionName) ||
|
|
408
|
+
undefined;
|
|
398
409
|
if (!command) {
|
|
399
410
|
Logger.debug(`❌️ Command with name ${interactionName} not found.`);
|
|
400
411
|
return;
|
|
@@ -406,8 +417,15 @@ export class Command extends command {
|
|
|
406
417
|
}
|
|
407
418
|
return;
|
|
408
419
|
}
|
|
409
|
-
const subCommandName = command.type === "slash" &&
|
|
410
|
-
|
|
420
|
+
const subCommandName = command.type === "slash" &&
|
|
421
|
+
interaction instanceof ChatInputCommandInteraction
|
|
422
|
+
? interaction.options.getSubcommand(false)
|
|
423
|
+
: null;
|
|
424
|
+
const isCommandTypeMatch = command.isSlashCommand() ||
|
|
425
|
+
command.isContextMenuCommand() ||
|
|
426
|
+
command.isButtonAction() ||
|
|
427
|
+
command.isSelectMenuAction() ||
|
|
428
|
+
command.isModalAction();
|
|
411
429
|
if (!isCommandTypeMatch) {
|
|
412
430
|
Logger.debug(`❌️ Command ${interactionName} is not a ${command.type} command`);
|
|
413
431
|
return;
|
|
@@ -450,7 +468,8 @@ export class Command extends command {
|
|
|
450
468
|
else if (command.isButtonAction() && interaction.isButton()) {
|
|
451
469
|
await command.execute(interaction);
|
|
452
470
|
}
|
|
453
|
-
else if (command.isSelectMenuAction() &&
|
|
471
|
+
else if (command.isSelectMenuAction() &&
|
|
472
|
+
interaction.isStringSelectMenu()) {
|
|
454
473
|
await command.execute(interaction);
|
|
455
474
|
}
|
|
456
475
|
else if (command.isModalAction() && interaction.isModalSubmit()) {
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,IAAI,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAUhF,qBAAa,MAAO,SAAQ,MAAM;IAChC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC;IAEnC,OAAO,CAAC,MAAM,CAAC,cAAc;gBAsEjB,MAAM,EAAE,OAAO;WAUb,GAAG,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;WAOhD,aAAa,IAAI,OAAO;CAGvC"}
|
package/dist/core/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GatewayIntentBits } from "discord.js";
|
|
2
|
-
import { Config as config } from "
|
|
2
|
+
import { Config as config } from "../types/index.js";
|
|
3
3
|
import { Log } from "./logger.js";
|
|
4
4
|
class EnvConfigError extends Error {
|
|
5
5
|
constructor(message, options) {
|
|
@@ -29,14 +29,7 @@ export class Config extends config {
|
|
|
29
29
|
throw new EnvConfigError("adminIds must be an array of strings.");
|
|
30
30
|
}
|
|
31
31
|
if (config.options.logging) {
|
|
32
|
-
if (![
|
|
33
|
-
"trace",
|
|
34
|
-
"debug",
|
|
35
|
-
"info",
|
|
36
|
-
"warning",
|
|
37
|
-
"error",
|
|
38
|
-
"fatal",
|
|
39
|
-
].includes(config.options.logging.level)) {
|
|
32
|
+
if (!["trace", "debug", "info", "warning", "error", "fatal"].includes(config.options.logging.level)) {
|
|
40
33
|
throw new EnvConfigError("Logging level must be one of 'trace', 'debug', 'info', 'warning', 'error', 'fatal'.");
|
|
41
34
|
}
|
|
42
35
|
if (typeof config.options.logging.enableFileLogging !== "boolean") {
|
package/dist/core/error.d.ts
CHANGED
package/dist/core/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/core/error.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/core/error.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjE,qBAAa,YAAa,SAAQ,YAAY;IAW5C,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAOhC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAMjC,OAAO,CAAC,MAAM,CAAC,eAAe;WAehB,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;CAM1D"}
|
package/dist/core/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Core } from "./client.js";
|
|
2
2
|
import { getCustomCoreLogger } from "./logger.js";
|
|
3
|
-
import { ErrorHandler as errorhandler } from "
|
|
3
|
+
import { ErrorHandler as errorhandler } from "../types/index.js";
|
|
4
4
|
const Logger = getCustomCoreLogger("errorHandler");
|
|
5
5
|
export class ErrorHandler extends errorhandler {
|
|
6
6
|
static {
|
package/dist/core/event.d.ts
CHANGED
package/dist/core/event.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/core/event.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/core/event.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAe,MAAM,mBAAmB,CAAC;AAMhE,qBAAa,KAAM,SAAQ,KAAK;IAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAgB;WAEjB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mBAKvC,gBAAgB;IA2CrC,OAAO,CAAC,MAAM,CAAC,cAAc;CAiB9B"}
|
package/dist/core/event.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { getCustomCoreLogger } from "./logger.js";
|
|
4
|
-
import { Event as event } from "
|
|
4
|
+
import { Event as event } from "../types/index.js";
|
|
5
5
|
const Logger = getCustomCoreLogger("events");
|
|
6
6
|
export class Event extends event {
|
|
7
7
|
static events = [];
|
package/dist/core/logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLogger, type Logger as LoggerT } from "@logtape/logtape";
|
|
2
|
-
import { Log as log, type Logging } from "
|
|
2
|
+
import { Log as log, type Logging } from "../types/index.js";
|
|
3
3
|
export declare class Log extends log {
|
|
4
4
|
private static isInitalized;
|
|
5
5
|
static readonly LOGGER_READY: symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,SAAS,EACT,KAAK,MAAM,IAAI,OAAO,EACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAU,GAAG,IAAI,GAAG,EAAE,KAAK,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,SAAS,EACT,KAAK,MAAM,IAAI,OAAO,EACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAU,GAAG,IAAI,GAAG,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErE,qBAAa,GAAI,SAAQ,GAAG;IAC1B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAkB;IAC7C,gBAAuB,YAAY,EAAE,MAAM,CAEzC;IACF,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAgB;IAEtC,OAAO,CAAC,MAAM,CAAC,uBAAuB;WAOlB,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA+DzE,WAAkB,GAAG,IAAI,UAAU,CAAC,OAAO,SAAS,CAAC,CAEpD;WAEa,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;WAItC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;WAInB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/C;AAED,eAAO,MAAM,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAOjD,CAAC;AACF,eAAO,MAAM,UAAU,EAAE,OAAkC,CAAC;AAC5D,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,WAK9D"}
|
package/dist/core/logger.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { configure, getConsoleSink, getAnsiColorFormatter, getLogger, } from "@logtape/logtape";
|
|
4
4
|
import { getRotatingFileSink } from "@logtape/file";
|
|
5
|
-
import { Config, Log as log } from "
|
|
5
|
+
import { Config, Log as log } from "../types/index.js";
|
|
6
6
|
export class Log extends log {
|
|
7
7
|
static isInitalized = false;
|
|
8
8
|
static LOGGER_READY = Symbol.for("diskernel.logger.ready");
|
|
@@ -25,7 +25,7 @@ export class Log extends log {
|
|
|
25
25
|
if (!options) {
|
|
26
26
|
options = Config.get("options")?.logging ?? {
|
|
27
27
|
level: "info",
|
|
28
|
-
enableFileLogging: false
|
|
28
|
+
enableFileLogging: false,
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
if (options.enableFileLogging) {
|
|
@@ -46,7 +46,7 @@ export class Log extends log {
|
|
|
46
46
|
maxFiles: 4,
|
|
47
47
|
nonBlocking: true,
|
|
48
48
|
bufferSize: 512 * 1024,
|
|
49
|
-
flushInterval: 100
|
|
49
|
+
flushInterval: 100,
|
|
50
50
|
}),
|
|
51
51
|
}
|
|
52
52
|
: {}),
|
|
@@ -61,18 +61,12 @@ export class Log extends log {
|
|
|
61
61
|
{
|
|
62
62
|
category: "[diskernel]",
|
|
63
63
|
lowestLevel: options.level ?? "info",
|
|
64
|
-
sinks: [
|
|
65
|
-
"console",
|
|
66
|
-
...(options.enableFileLogging ? ["file"] : []),
|
|
67
|
-
],
|
|
64
|
+
sinks: ["console", ...(options.enableFileLogging ? ["file"] : [])],
|
|
68
65
|
},
|
|
69
66
|
{
|
|
70
67
|
category: "main",
|
|
71
68
|
lowestLevel: options.level ?? "info",
|
|
72
|
-
sinks: [
|
|
73
|
-
"console",
|
|
74
|
-
...(options.enableFileLogging ? ["file"] : []),
|
|
75
|
-
],
|
|
69
|
+
sinks: ["console", ...(options.enableFileLogging ? ["file"] : [])],
|
|
76
70
|
},
|
|
77
71
|
],
|
|
78
72
|
});
|
|
@@ -95,9 +89,15 @@ export class Log extends log {
|
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
91
|
export const Logger = (cat) => {
|
|
98
|
-
return getLogger([
|
|
92
|
+
return getLogger([
|
|
93
|
+
"main",
|
|
94
|
+
...(cat instanceof Array ? cat : cat ? [cat] : []),
|
|
95
|
+
]);
|
|
99
96
|
};
|
|
100
97
|
export const CoreLogger = getLogger("[diskernel]");
|
|
101
98
|
export function getCustomCoreLogger(category) {
|
|
102
|
-
return getLogger([
|
|
99
|
+
return getLogger([
|
|
100
|
+
"[diskernel]",
|
|
101
|
+
...(category instanceof Array ? category : [category]),
|
|
102
|
+
]);
|
|
103
103
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACnE,eAAO,MAAM,SAAS;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACnE,eAAO,MAAM,SAAS;;;;;;;;CAQrB,CAAC;AAEF,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,5 +5,13 @@ import { Config } from "./core/config.js";
|
|
|
5
5
|
import { ErrorHandler } from "./core/error.js";
|
|
6
6
|
import { Log, Logger } from "./core/logger.js";
|
|
7
7
|
export { Core, Command, Event, Config, ErrorHandler, Log, Logger };
|
|
8
|
-
export const Diskernel = {
|
|
8
|
+
export const Diskernel = {
|
|
9
|
+
Core,
|
|
10
|
+
Command,
|
|
11
|
+
Event,
|
|
12
|
+
Config,
|
|
13
|
+
ErrorHandler,
|
|
14
|
+
Log,
|
|
15
|
+
Logger,
|
|
16
|
+
};
|
|
9
17
|
export * from "./types/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/types/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/types/command.ts"],"names":[],"mappings":"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AQ,GACd,aAAa,GACb,CAAC,SAAS,YAAY,GACpB,iBAAiB,GACjB,CAAC,SAAS,OAAO,GACf,YAAY,GACZ,KAAK,CAAC;AAEhB,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,mBAAmB,GACnB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,YAAY,CAAC;AAE1E,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC"}
|
package/dist/types/command.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEpD,MAAM,MAAM,OAAO,GACf;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEpD,MAAM,MAAM,OAAO,GACf;IACE,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;IAClE,iBAAiB,EAAE,KAAK,CAAC;CAC1B,GACD;IACE,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;IAClE,iBAAiB,EAAE,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,MAAM,WAAW,cAAc;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,yBAAyB,EAAE,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
package/dist/types/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|