diskernel 0.1.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.
Files changed (57) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +7 -0
  3. package/dist/core/client.d.ts +9 -0
  4. package/dist/core/client.d.ts.map +1 -0
  5. package/dist/core/client.js +70 -0
  6. package/dist/core/command.d.ts +29 -0
  7. package/dist/core/command.d.ts.map +1 -0
  8. package/dist/core/command.js +570 -0
  9. package/dist/core/config.d.ts +9 -0
  10. package/dist/core/config.d.ts.map +1 -0
  11. package/dist/core/config.js +82 -0
  12. package/dist/core/error.d.ts +8 -0
  13. package/dist/core/error.d.ts.map +1 -0
  14. package/dist/core/error.js +34 -0
  15. package/dist/core/event.d.ts +9 -0
  16. package/dist/core/event.d.ts.map +1 -0
  17. package/dist/core/event.js +66 -0
  18. package/dist/core/logger.d.ts +17 -0
  19. package/dist/core/logger.d.ts.map +1 -0
  20. package/dist/core/logger.js +103 -0
  21. package/dist/index.d.ts +18 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +9 -0
  24. package/dist/types/abstract/client.abc.d.ts +7 -0
  25. package/dist/types/abstract/client.abc.d.ts.map +1 -0
  26. package/dist/types/abstract/client.abc.js +7 -0
  27. package/dist/types/abstract/command.abc.d.ts +8 -0
  28. package/dist/types/abstract/command.abc.d.ts.map +1 -0
  29. package/dist/types/abstract/command.abc.js +15 -0
  30. package/dist/types/abstract/config.abc.d.ts +6 -0
  31. package/dist/types/abstract/config.abc.d.ts.map +1 -0
  32. package/dist/types/abstract/config.abc.js +6 -0
  33. package/dist/types/abstract/error.abc.d.ts +4 -0
  34. package/dist/types/abstract/error.abc.d.ts.map +1 -0
  35. package/dist/types/abstract/error.abc.js +4 -0
  36. package/dist/types/abstract/event.abc.d.ts +5 -0
  37. package/dist/types/abstract/event.abc.d.ts.map +1 -0
  38. package/dist/types/abstract/event.abc.js +3 -0
  39. package/dist/types/abstract/index.d.ts +7 -0
  40. package/dist/types/abstract/index.d.ts.map +1 -0
  41. package/dist/types/abstract/index.js +6 -0
  42. package/dist/types/abstract/logger.abc.d.ts +5 -0
  43. package/dist/types/abstract/logger.abc.d.ts.map +1 -0
  44. package/dist/types/abstract/logger.abc.js +6 -0
  45. package/dist/types/command.d.ts +104 -0
  46. package/dist/types/command.d.ts.map +1 -0
  47. package/dist/types/command.js +79 -0
  48. package/dist/types/config.d.ts +29 -0
  49. package/dist/types/config.d.ts.map +1 -0
  50. package/dist/types/config.js +1 -0
  51. package/dist/types/event.d.ts +7 -0
  52. package/dist/types/event.d.ts.map +1 -0
  53. package/dist/types/event.js +1 -0
  54. package/dist/types/index.d.ts +5 -0
  55. package/dist/types/index.d.ts.map +1 -0
  56. package/dist/types/index.js +4 -0
  57. package/package.json +67 -0
@@ -0,0 +1,34 @@
1
+ import { Core } from "./client.js";
2
+ import { getCustomCoreLogger } from "./logger.js";
3
+ import { ErrorHandler as errorhandler } from "#types";
4
+ const Logger = getCustomCoreLogger("errorHandler");
5
+ export class ErrorHandler extends errorhandler {
6
+ static {
7
+ process.on("uncaughtException", (e) => this.uncaughtException(e));
8
+ process.on("unhandledRejection", (reason, promise) => this.unhandledRejection(reason, promise));
9
+ process.on("SIGINT", () => this.shutdownHandler("SIGINT"));
10
+ process.on("SIGTERM", () => this.shutdownHandler("SIGTERM"));
11
+ process.on("SIGQUIT", () => this.shutdownHandler("SIGQUIT"));
12
+ }
13
+ static uncaughtException(error) {
14
+ Logger.fatal(`Uncaught Exception: ${error.message}${error.stack ? `\nStack Trace: ${error.stack}` : ""}${error.cause ? `\nCaused by: ${error.cause}` : ""}`);
15
+ this.shutdownHandler("uncaughtException", error.message);
16
+ }
17
+ static unhandledRejection(reason, promise) {
18
+ Logger.warn(`Unhandled Rejection at: ${promise}${reason instanceof Error ? `\nReason: ${reason.message}${reason.stack ? `\nStack Trace: ${reason.stack}` : ""}${reason.cause ? `\nCaused by: ${reason.cause}` : ""}` : `\nReason: ${reason}`}`);
19
+ }
20
+ static shutdownHandler(signal, reason) {
21
+ Logger.warn(`Shutdown due to ${signal ?? "unknown"}${reason ? `, Reason: ${reason}` : ""}...`);
22
+ try {
23
+ Core.stop();
24
+ }
25
+ catch (_) {
26
+ // ignore errors when Core is not initialized yet
27
+ }
28
+ process.exit(signal === "normal shutdown" ? 0 : 1);
29
+ }
30
+ static fatal(reason, error) {
31
+ Logger.fatal(`\n :( A fatal error has occured :( \n Reason: ${reason ?? "No reason provided"} \n Error: ${error?.message ?? "No error provided"} \n Stack: ${error?.stack ?? "No stack provided"} \n Cause: ${error?.cause ?? "No cause provided"}`);
32
+ this.shutdownHandler("fatal error");
33
+ }
34
+ }
@@ -0,0 +1,9 @@
1
+ import type { Client } from "discord.js";
2
+ import { Event as event } from "#types";
3
+ export declare class Event extends event {
4
+ private static events;
5
+ static initalize(client: Client): Promise<void>;
6
+ private static loadEventFromDir;
7
+ private static registerEvents;
8
+ }
9
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +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,QAAQ,CAAC;AAMrD,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"}
@@ -0,0 +1,66 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { getCustomCoreLogger } from "./logger.js";
4
+ import { Event as event } from "#types";
5
+ const Logger = getCustomCoreLogger("events");
6
+ export class Event extends event {
7
+ static events = [];
8
+ static async initalize(client) {
9
+ await this.loadEventFromDir(path.resolve(process.cwd(), "dist", "events"));
10
+ this.registerEvents(client);
11
+ }
12
+ static async loadEventFromDir(dir) {
13
+ try {
14
+ const files = await fs.promises.readdir(dir);
15
+ await Promise.all(files
16
+ .filter((f) => f.endsWith(".js"))
17
+ .map(async (file) => {
18
+ const filePath = path.join(dir, file);
19
+ try {
20
+ const module = await import(filePath);
21
+ let event = module.default ?? Object.values(module)[0];
22
+ if (event && typeof event === "function" && event.prototype) {
23
+ try {
24
+ event = new event();
25
+ }
26
+ catch (_e) {
27
+ Logger.warn(`❌️ Failed to instantiate event class: ${file}`);
28
+ return;
29
+ }
30
+ }
31
+ if (event &&
32
+ typeof event.event === "string" &&
33
+ typeof event.execute === "function") {
34
+ this.events.push(event);
35
+ Logger.debug(`✅️ Loaded event: ${file}`);
36
+ }
37
+ else {
38
+ Logger.warn(`❌️ Invalid event: ${file}`);
39
+ }
40
+ }
41
+ catch {
42
+ Logger.warn(`❌️ Failed to import event: ${file}`);
43
+ }
44
+ }));
45
+ return true;
46
+ }
47
+ catch {
48
+ Logger.warn(`⚠ Event folder does not exist: ${dir}`);
49
+ return false;
50
+ }
51
+ }
52
+ static registerEvents(client) {
53
+ for (const event of this.events) {
54
+ Logger.debug(`Processing event: ${event.event}`);
55
+ if (event.once) {
56
+ client.once(event.event, (...args) => event.execute(...args));
57
+ Logger.debug(`✅️ Registered once event: ${event.event}`);
58
+ }
59
+ else {
60
+ client.on(event.event, (...args) => event.execute(...args));
61
+ Logger.debug(`✅️ Registered normal event: ${event.event}`);
62
+ }
63
+ }
64
+ return;
65
+ }
66
+ }
@@ -0,0 +1,17 @@
1
+ import { getLogger, type Logger as LoggerT } from "@logtape/logtape";
2
+ import { Log as log, type Logging } from "#types";
3
+ export declare class Log extends log {
4
+ private static isInitalized;
5
+ static readonly LOGGER_READY: symbol;
6
+ private static _ready?;
7
+ private static createLogDirIfNotExists;
8
+ static initalizeMainLogger(options?: Logging): Promise<void>;
9
+ static get get(): ReturnType<typeof getLogger>;
10
+ static setReady(promise: Promise<void>): void;
11
+ static getReady(): Promise<void>;
12
+ static whenReady(): Promise<void>;
13
+ }
14
+ export declare const Logger: (cat?: string | string[]) => LoggerT;
15
+ export declare const CoreLogger: LoggerT;
16
+ export declare function getCustomCoreLogger(category: string | string[]): LoggerT;
17
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +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,QAAQ,CAAC;AAE1D,qBAAa,GAAI,SAAQ,GAAG;IAC1B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAkB;IAC7C,gBAAuB,YAAY,EAAE,MAAM,CAAwC;IACnF,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAgB;IAEtC,OAAO,CAAC,MAAM,CAAC,uBAAuB;WAQlB,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqEzE,WAAkB,GAAG,IAAI,UAAU,CAAC,OAAO,SAAS,CAAC,CAEpD;WAGa,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,OAEjD,CAAC;AACF,eAAO,MAAM,UAAU,EAAE,OAAkC,CAAC;AAC5D,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,WAE9D"}
@@ -0,0 +1,103 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { configure, getConsoleSink, getAnsiColorFormatter, getLogger, } from "@logtape/logtape";
4
+ import { getRotatingFileSink } from "@logtape/file";
5
+ import { Config, Log as log } from "#types";
6
+ export class Log extends log {
7
+ static isInitalized = false;
8
+ static LOGGER_READY = Symbol.for("diskernel.logger.ready");
9
+ static _ready;
10
+ static createLogDirIfNotExists(dir) {
11
+ dir = path.dirname(dir);
12
+ if (!fs.existsSync(dir)) {
13
+ fs.mkdirSync(dir, { recursive: true });
14
+ }
15
+ }
16
+ static async initalizeMainLogger(options) {
17
+ if (this._ready) {
18
+ await this._ready;
19
+ return;
20
+ }
21
+ const ready = (async () => {
22
+ if (this.isInitalized) {
23
+ return;
24
+ }
25
+ if (!options) {
26
+ options = Config.get("options")?.logging ?? {
27
+ level: "info",
28
+ enableFileLogging: false
29
+ };
30
+ }
31
+ if (options.enableFileLogging) {
32
+ this.createLogDirIfNotExists(options.logFilePath);
33
+ }
34
+ await configure({
35
+ sinks: {
36
+ meta: getConsoleSink({
37
+ formatter: getAnsiColorFormatter(),
38
+ }),
39
+ console: getConsoleSink({
40
+ formatter: getAnsiColorFormatter(),
41
+ }),
42
+ ...(options.enableFileLogging
43
+ ? {
44
+ file: getRotatingFileSink(options.logFilePath, {
45
+ maxSize: 4 * 1024 * 1024,
46
+ maxFiles: 4,
47
+ nonBlocking: true,
48
+ bufferSize: 512 * 1024,
49
+ flushInterval: 100
50
+ }),
51
+ }
52
+ : {}),
53
+ },
54
+ filters: {},
55
+ loggers: [
56
+ {
57
+ category: ["logtape", "meta"],
58
+ lowestLevel: "warning",
59
+ sinks: ["meta"],
60
+ },
61
+ {
62
+ category: "[diskernel]",
63
+ lowestLevel: options.level ?? "info",
64
+ sinks: [
65
+ "console",
66
+ ...(options.enableFileLogging ? ["file"] : []),
67
+ ],
68
+ },
69
+ {
70
+ category: "main",
71
+ lowestLevel: options.level ?? "info",
72
+ sinks: [
73
+ "console",
74
+ ...(options.enableFileLogging ? ["file"] : []),
75
+ ],
76
+ },
77
+ ],
78
+ });
79
+ this.isInitalized = true;
80
+ })();
81
+ this.setReady(ready);
82
+ await ready;
83
+ }
84
+ static get get() {
85
+ return getLogger("main");
86
+ }
87
+ static setReady(promise) {
88
+ this._ready = promise;
89
+ }
90
+ static getReady() {
91
+ return this._ready ?? Promise.resolve();
92
+ }
93
+ static async whenReady() {
94
+ await this.getReady();
95
+ }
96
+ }
97
+ export const Logger = (cat) => {
98
+ return getLogger(["main", ...(cat instanceof Array ? cat : cat ? [cat] : [])]);
99
+ };
100
+ export const CoreLogger = getLogger("[diskernel]");
101
+ export function getCustomCoreLogger(category) {
102
+ return getLogger(["[diskernel]", ...(category instanceof Array ? category : [category])]);
103
+ }
@@ -0,0 +1,18 @@
1
+ import { Core } from "./core/client.js";
2
+ import { Command } from "./core/command.js";
3
+ import { Event } from "./core/event.js";
4
+ import { Config } from "./core/config.js";
5
+ import { ErrorHandler } from "./core/error.js";
6
+ import { Log, Logger } from "./core/logger.js";
7
+ export { Core, Command, Event, Config, ErrorHandler, Log, Logger };
8
+ export declare const Diskernel: {
9
+ Core: typeof Core;
10
+ Command: typeof Command;
11
+ Event: typeof Event;
12
+ Config: typeof Config;
13
+ ErrorHandler: typeof ErrorHandler;
14
+ Log: typeof Log;
15
+ Logger: (cat?: string | string[]) => import("@logtape/logtape").Logger;
16
+ };
17
+ export * from "./types/index.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;;;;;;;;CAA8D,CAAC;AAErF,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { Core } from "./core/client.js";
2
+ import { Command } from "./core/command.js";
3
+ import { Event } from "./core/event.js";
4
+ import { Config } from "./core/config.js";
5
+ import { ErrorHandler } from "./core/error.js";
6
+ import { Log, Logger } from "./core/logger.js";
7
+ export { Core, Command, Event, Config, ErrorHandler, Log, Logger };
8
+ export const Diskernel = { Core, Command, Event, Config, ErrorHandler, Log, Logger };
9
+ export * from "./types/index.js";
@@ -0,0 +1,7 @@
1
+ import type { Client } from "discord.js";
2
+ export declare abstract class Core {
3
+ static get Client(): Client | undefined;
4
+ static start(): Promise<void>;
5
+ static stop(): void;
6
+ }
7
+ //# sourceMappingURL=client.abc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.abc.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/client.abc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,8BAAsB,IAAI;IACxB,MAAM,KAAK,MAAM,IAAI,MAAM,GAAG,SAAS,CAEtC;WACY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IACnC,MAAM,CAAC,IAAI,IAAI,IAAI;CACpB"}
@@ -0,0 +1,7 @@
1
+ export class Core {
2
+ static get Client() {
3
+ return undefined;
4
+ }
5
+ static async start() { }
6
+ static stop() { }
7
+ }
@@ -0,0 +1,8 @@
1
+ export declare abstract class Command {
2
+ static initalize(): Promise<void>;
3
+ static registerFromName(_name: string): Promise<boolean>;
4
+ static registerFromNameAndGuildID(_name: string, _guildID: string): Promise<boolean>;
5
+ static unregisterFromName(_name: string): Promise<boolean>;
6
+ static unregisterFromNameAndGuildID(_name: string, _guildID: string): Promise<boolean>;
7
+ }
8
+ //# sourceMappingURL=command.abc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.abc.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/command.abc.ts"],"names":[],"mappings":"AAAA,8BAAsB,OAAO;WACd,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;WAC1B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAGjD,0BAA0B,CACrC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;WAGN,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAGnD,4BAA4B,CACvC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;CAGpB"}
@@ -0,0 +1,15 @@
1
+ export class Command {
2
+ static async initalize() { }
3
+ static async registerFromName(_name) {
4
+ return false;
5
+ }
6
+ static async registerFromNameAndGuildID(_name, _guildID) {
7
+ return false;
8
+ }
9
+ static async unregisterFromName(_name) {
10
+ return false;
11
+ }
12
+ static async unregisterFromNameAndGuildID(_name, _guildID) {
13
+ return false;
14
+ }
15
+ }
@@ -0,0 +1,6 @@
1
+ import type { ConfigT } from "../config.js";
2
+ export declare abstract class Config {
3
+ constructor();
4
+ static get<K extends keyof ConfigT>(_key: K): ConfigT[K] | undefined;
5
+ }
6
+ //# sourceMappingURL=config.abc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.abc.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/config.abc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,8BAAsB,MAAM;;IAE1B,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS;CAGrE"}
@@ -0,0 +1,6 @@
1
+ export class Config {
2
+ constructor() { }
3
+ static get(_key) {
4
+ return undefined;
5
+ }
6
+ }
@@ -0,0 +1,4 @@
1
+ export declare abstract class ErrorHandler {
2
+ static fatal(_reason?: string, _error?: Error): void;
3
+ }
4
+ //# sourceMappingURL=error.abc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.abc.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/error.abc.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY;IAEhC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI;CACrD"}
@@ -0,0 +1,4 @@
1
+ export class ErrorHandler {
2
+ static { }
3
+ static fatal(_reason, _error) { }
4
+ }
@@ -0,0 +1,5 @@
1
+ import type { Client } from "discord.js";
2
+ export declare abstract class Event {
3
+ static initalize(_client: Client<boolean>): Promise<void>;
4
+ }
5
+ //# sourceMappingURL=event.abc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.abc.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/event.abc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,8BAAsB,KAAK;WACZ,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAChE"}
@@ -0,0 +1,3 @@
1
+ export class Event {
2
+ static async initalize(_client) { }
3
+ }
@@ -0,0 +1,7 @@
1
+ export * from "./command.abc.js";
2
+ export * from "./client.abc.js";
3
+ export * from "./config.abc.js";
4
+ export * from "./error.abc.js";
5
+ export * from "./event.abc.js";
6
+ export * from "./logger.abc.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./command.abc.js";
2
+ export * from "./client.abc.js";
3
+ export * from "./config.abc.js";
4
+ export * from "./error.abc.js";
5
+ export * from "./event.abc.js";
6
+ export * from "./logger.abc.js";
@@ -0,0 +1,5 @@
1
+ import type { getLogger } from "@logtape/logtape";
2
+ export declare abstract class Log {
3
+ static get get(): ReturnType<typeof getLogger>;
4
+ }
5
+ //# sourceMappingURL=logger.abc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.abc.d.ts","sourceRoot":"","sources":["../../../src/types/abstract/logger.abc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,8BAAsB,GAAG;IAEvB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,OAAO,SAAS,CAAC,CAE7C;CACF"}
@@ -0,0 +1,6 @@
1
+ export class Log {
2
+ static { }
3
+ static get get() {
4
+ return {};
5
+ }
6
+ }
@@ -0,0 +1,104 @@
1
+ import type { AutocompleteInteraction, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, ModalSubmitInteraction, ButtonInteraction, StringSelectMenuInteraction, UserContextMenuCommandInteraction } from "discord.js";
2
+ type InteractionKind = "slash" | "userContextMenu" | "messageContextMenu" | "button" | "selectMenu" | "modal";
3
+ export interface CooldownData {
4
+ globalCooldownTime?: number;
5
+ userCooldownTime?: number;
6
+ lastUsedGlobal?: number;
7
+ user?: Map<string, number>;
8
+ }
9
+ export interface OptionT {
10
+ name: string;
11
+ description: string;
12
+ type: "string" | "integer" | "boolean" | "user" | "channel" | "role";
13
+ required: boolean;
14
+ choices?: {
15
+ name: string;
16
+ value: string;
17
+ }[];
18
+ }
19
+ export declare abstract class BaseInteraction<T extends InteractionKind> {
20
+ readonly type: T;
21
+ abstract isAdminOnly?: boolean;
22
+ abstract isDevOnly?: boolean;
23
+ abstract isCooldownEnabled?: boolean;
24
+ abstract globalCooldownTime?: number;
25
+ abstract userCooldownTime?: number;
26
+ protected constructor(type: T);
27
+ description?: string;
28
+ parent?: string;
29
+ option?: OptionT[];
30
+ hasParent(): this is this & {
31
+ parent: string;
32
+ };
33
+ hasDescription(): this is this & {
34
+ description: string;
35
+ };
36
+ hasOptions(): this is this & {
37
+ option: OptionT[];
38
+ };
39
+ isUserContextCommand(): this is this & {
40
+ type: "userContextMenu";
41
+ };
42
+ isMessageContextCommand(): this is this & {
43
+ type: "messageContextMenu";
44
+ };
45
+ isContextMenuCommand(): this is this & {
46
+ type: "userContextMenu" | "messageContextMenu";
47
+ };
48
+ isSlashCommand(): this is this & {
49
+ type: "slash";
50
+ };
51
+ isButtonAction(): this is this & {
52
+ type: "button";
53
+ };
54
+ isSelectMenuAction(): this is this & {
55
+ type: "selectMenu";
56
+ };
57
+ isModalAction(): this is this & {
58
+ type: "modal";
59
+ };
60
+ }
61
+ export declare abstract class BaseCommand<T extends "slash" | "userContextMenu" | "messageContextMenu"> extends BaseInteraction<T> {
62
+ constructor(type: T);
63
+ abstract name: string;
64
+ }
65
+ export declare abstract class BaseAction<T extends "button" | "selectMenu" | "modal"> extends BaseInteraction<T> {
66
+ constructor(type: T);
67
+ abstract name: string;
68
+ }
69
+ export declare abstract class ButtonActionT extends BaseAction<"button"> {
70
+ constructor();
71
+ abstract execute(interaction: ButtonInteraction): Promise<void>;
72
+ }
73
+ export declare abstract class SelectMenuActionT extends BaseAction<"selectMenu"> {
74
+ constructor();
75
+ abstract execute(interaction: StringSelectMenuInteraction): Promise<void>;
76
+ }
77
+ export declare abstract class ModalActionT extends BaseAction<"modal"> {
78
+ constructor();
79
+ abstract execute(interaction: ModalSubmitInteraction): Promise<void>;
80
+ }
81
+ export declare abstract class SlashCommandT extends BaseCommand<"slash"> {
82
+ constructor();
83
+ abstract name: string;
84
+ abstract description: string;
85
+ abstract autocomplete?(interaction: AutocompleteInteraction): Promise<void>;
86
+ abstract execute(interaction: ChatInputCommandInteraction): Promise<void>;
87
+ }
88
+ export declare abstract class UserContextCommandT extends BaseCommand<"userContextMenu"> {
89
+ constructor();
90
+ abstract name: string;
91
+ abstract execute(interaction: UserContextMenuCommandInteraction): Promise<void>;
92
+ }
93
+ export declare abstract class MessageContextCommandT extends BaseCommand<"messageContextMenu"> {
94
+ constructor();
95
+ abstract name: string;
96
+ abstract execute(interaction: MessageContextMenuCommandInteraction): Promise<void>;
97
+ }
98
+ export type CommandT<T extends "slash" | "context", K extends "User" | "Message" | undefined = undefined> = T extends "slash" ? SlashCommandT : K extends "User" ? UserContextCommandT : K extends "Message" ? MessageContextCommandT : never;
99
+ export type ActionT<T extends "button" | "selectMenu" | "modal"> = T extends "button" ? ButtonActionT : T extends "selectMenu" ? SelectMenuActionT : T extends "modal" ? ModalActionT : never;
100
+ export type AnyCommandT = SlashCommandT | UserContextCommandT | MessageContextCommandT;
101
+ export type AnyActionT = ButtonActionT | SelectMenuActionT | ModalActionT;
102
+ export type AnyInteractionT = AnyCommandT | AnyActionT;
103
+ export {};
104
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/types/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,2BAA2B,EAC3B,oCAAoC,EACpC,sBAAsB,EACtB,iBAAiB,EACjB,2BAA2B,EAC3B,iCAAiC,EACpC,MAAM,YAAY,CAAC;AAEpB,KAAK,eAAe,GAAG,OAAO,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAAC;AAE9G,MAAM,WAAW,YAAY;IACzB,kBAAkB,CA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AM,UAAU,GAChB,aAAa,GACb,iBAAiB,GACjB,YAAY,CAAC;AAEnB,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC"}
@@ -0,0 +1,79 @@
1
+ export class BaseInteraction {
2
+ type;
3
+ constructor(type) {
4
+ this.type = type;
5
+ }
6
+ description;
7
+ parent;
8
+ option;
9
+ hasParent() {
10
+ return typeof this.parent === "string";
11
+ }
12
+ hasDescription() {
13
+ return typeof this.description === "string";
14
+ }
15
+ hasOptions() {
16
+ return Array.isArray(this.option) && this.option.length > 0;
17
+ }
18
+ isUserContextCommand() {
19
+ return this.type === "userContextMenu";
20
+ }
21
+ isMessageContextCommand() {
22
+ return this.type === "messageContextMenu";
23
+ }
24
+ isContextMenuCommand() {
25
+ return this.isUserContextCommand() || this.isMessageContextCommand();
26
+ }
27
+ isSlashCommand() {
28
+ return this.type === "slash";
29
+ }
30
+ isButtonAction() {
31
+ return this.type === "button";
32
+ }
33
+ isSelectMenuAction() {
34
+ return this.type === "selectMenu";
35
+ }
36
+ isModalAction() {
37
+ return this.type === "modal";
38
+ }
39
+ }
40
+ export class BaseCommand extends BaseInteraction {
41
+ constructor(type) {
42
+ super(type);
43
+ }
44
+ }
45
+ export class BaseAction extends BaseInteraction {
46
+ constructor(type) {
47
+ super(type);
48
+ }
49
+ }
50
+ export class ButtonActionT extends BaseAction {
51
+ constructor() {
52
+ super("button");
53
+ }
54
+ }
55
+ export class SelectMenuActionT extends BaseAction {
56
+ constructor() {
57
+ super("selectMenu");
58
+ }
59
+ }
60
+ export class ModalActionT extends BaseAction {
61
+ constructor() {
62
+ super("modal");
63
+ }
64
+ }
65
+ export class SlashCommandT extends BaseCommand {
66
+ constructor() {
67
+ super("slash");
68
+ }
69
+ }
70
+ export class UserContextCommandT extends BaseCommand {
71
+ constructor() {
72
+ super("userContextMenu");
73
+ }
74
+ }
75
+ export class MessageContextCommandT extends BaseCommand {
76
+ constructor() {
77
+ super("messageContextMenu");
78
+ }
79
+ }
@@ -0,0 +1,29 @@
1
+ import { GatewayIntentBits } from "discord.js";
2
+ export type Intent = keyof typeof GatewayIntentBits;
3
+ export type Logging = {
4
+ level: "trace" | "debug" | "info" | "warning" | "error" | "fatal";
5
+ enableFileLogging: false;
6
+ } | {
7
+ level: "trace" | "debug" | "info" | "warning" | "error" | "fatal";
8
+ enableFileLogging: true;
9
+ logFilePath: string;
10
+ };
11
+ export interface FeatureOptions {
12
+ enableCommandAutoload: boolean;
13
+ commandAutoloadPath?: string;
14
+ enableEventAutoload: boolean;
15
+ eventAutoloadPath?: string;
16
+ enableAdminCommands: boolean;
17
+ enableDevelopmentCommands: boolean;
18
+ }
19
+ export interface Options {
20
+ adminIds?: string[];
21
+ logging: Logging;
22
+ feature: FeatureOptions;
23
+ }
24
+ export interface ConfigT {
25
+ TOKEN: string;
26
+ intents: Intent[];
27
+ options: Options;
28
+ }
29
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +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;IACA,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;IAClE,iBAAiB,EAAE,KAAK,CAAC;CAC1B,GACC;IACA,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,CAAA;AAEH,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"}
@@ -0,0 +1 @@
1
+ import { GatewayIntentBits } from "discord.js";