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.
- package/LICENSE +28 -0
- package/README.md +7 -0
- package/dist/core/client.d.ts +9 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +70 -0
- package/dist/core/command.d.ts +29 -0
- package/dist/core/command.d.ts.map +1 -0
- package/dist/core/command.js +570 -0
- package/dist/core/config.d.ts +9 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +82 -0
- package/dist/core/error.d.ts +8 -0
- package/dist/core/error.d.ts.map +1 -0
- package/dist/core/error.js +34 -0
- package/dist/core/event.d.ts +9 -0
- package/dist/core/event.d.ts.map +1 -0
- package/dist/core/event.js +66 -0
- package/dist/core/logger.d.ts +17 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +103 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/types/abstract/client.abc.d.ts +7 -0
- package/dist/types/abstract/client.abc.d.ts.map +1 -0
- package/dist/types/abstract/client.abc.js +7 -0
- package/dist/types/abstract/command.abc.d.ts +8 -0
- package/dist/types/abstract/command.abc.d.ts.map +1 -0
- package/dist/types/abstract/command.abc.js +15 -0
- package/dist/types/abstract/config.abc.d.ts +6 -0
- package/dist/types/abstract/config.abc.d.ts.map +1 -0
- package/dist/types/abstract/config.abc.js +6 -0
- package/dist/types/abstract/error.abc.d.ts +4 -0
- package/dist/types/abstract/error.abc.d.ts.map +1 -0
- package/dist/types/abstract/error.abc.js +4 -0
- package/dist/types/abstract/event.abc.d.ts +5 -0
- package/dist/types/abstract/event.abc.d.ts.map +1 -0
- package/dist/types/abstract/event.abc.js +3 -0
- package/dist/types/abstract/index.d.ts +7 -0
- package/dist/types/abstract/index.d.ts.map +1 -0
- package/dist/types/abstract/index.js +6 -0
- package/dist/types/abstract/logger.abc.d.ts +5 -0
- package/dist/types/abstract/logger.abc.d.ts.map +1 -0
- package/dist/types/abstract/logger.abc.js +6 -0
- package/dist/types/command.d.ts +104 -0
- package/dist/types/command.d.ts.map +1 -0
- package/dist/types/command.js +79 -0
- package/dist/types/config.d.ts +29 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +1 -0
- package/dist/types/event.d.ts +7 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, ゆーゆー(yu-yu0202)
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Diskernel - A simplly Node.js Discord Bot framework
|
|
2
|
+
|
|
3
|
+
Diskernel は、Discord.js を更に簡単に扱えるようにしたライブラリです。
|
|
4
|
+
|
|
5
|
+
このライブラリはBSD3条項ライセンスとして公開されています。
|
|
6
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
7
|
+
詳細は LICENSE ファイルを参照してください。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "discord.js";
|
|
2
|
+
import { Core as core } from "#types";
|
|
3
|
+
export declare class Core extends core {
|
|
4
|
+
private static client;
|
|
5
|
+
static get Client(): Client | undefined;
|
|
6
|
+
static start(): Promise<void>;
|
|
7
|
+
static stop(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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,QAAQ,CAAC;AAWtC,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;WAoD5B,IAAI,IAAI,IAAI;CAS3B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Client } from "discord.js";
|
|
2
|
+
import { Config } from "./config.js";
|
|
3
|
+
import { getCustomCoreLogger, Log } from "./logger.js";
|
|
4
|
+
import { ErrorHandler } from "./error.js";
|
|
5
|
+
import { Command } from "./command.js";
|
|
6
|
+
import { Event } from "./event.js";
|
|
7
|
+
import { Core as core } from "#types";
|
|
8
|
+
class DiskernelError extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = "DiskernelError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const Logger = getCustomCoreLogger("master");
|
|
15
|
+
export class Core extends core {
|
|
16
|
+
static client = undefined;
|
|
17
|
+
static get Client() {
|
|
18
|
+
if (!this.client) {
|
|
19
|
+
Logger.warn("Client is not initialized!");
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return Core.client;
|
|
23
|
+
}
|
|
24
|
+
static async start() {
|
|
25
|
+
await Log.whenReady();
|
|
26
|
+
Logger.info("▶ Starting Bot...");
|
|
27
|
+
const intents = Config.get("intents");
|
|
28
|
+
Logger.debug(`Loaded ${intents.length} intents from configuration.`);
|
|
29
|
+
Core.client ??= new Client({ intents: intents });
|
|
30
|
+
Logger.info("✅ Initialized Discord client.");
|
|
31
|
+
this.client.on("debug", (m) => {
|
|
32
|
+
Logger.trace(m);
|
|
33
|
+
});
|
|
34
|
+
this.client.on("error", (e) => {
|
|
35
|
+
Logger.error(`\n ❌ Discord client error: ${e.message}\n Stack: ${e.stack}\n Cause: ${e.cause}`);
|
|
36
|
+
});
|
|
37
|
+
this.client.on("warn", (m) => {
|
|
38
|
+
Logger.warn(`⚠ Discord client warn: ${m}`);
|
|
39
|
+
});
|
|
40
|
+
Logger.info("▶ Logging in to Discord...");
|
|
41
|
+
Logger.trace(`Using token: ${Config.get("TOKEN").replace(/.(?=.{4})/g, "*")}`);
|
|
42
|
+
await this.client
|
|
43
|
+
.login(Config.get("TOKEN"))
|
|
44
|
+
.catch((e) => {
|
|
45
|
+
Logger.error("❌ Failed to login to Discord.");
|
|
46
|
+
ErrorHandler.fatal("Failed to login to Discord", e);
|
|
47
|
+
});
|
|
48
|
+
this.client.once("clientReady", () => {
|
|
49
|
+
Logger.info(`✅ Logged in as ${Core.client.user?.tag}`);
|
|
50
|
+
});
|
|
51
|
+
Logger.info("▶ Initializing commands...");
|
|
52
|
+
await Command.initialize();
|
|
53
|
+
Logger.info("✅ Commands initialized successfully.");
|
|
54
|
+
Logger.info("▶ Initializing events...");
|
|
55
|
+
if (!this.client) {
|
|
56
|
+
throw new DiskernelError("Discord client is not initialized before events.");
|
|
57
|
+
}
|
|
58
|
+
await Event.initalize(this.client);
|
|
59
|
+
Logger.info("✅ Events initialized successfully.");
|
|
60
|
+
}
|
|
61
|
+
static stop() {
|
|
62
|
+
Logger.info("▶ Stopping Bot...");
|
|
63
|
+
this.client?.destroy().catch((e) => {
|
|
64
|
+
throw new DiskernelError("Failed to destroy Discord client.", {
|
|
65
|
+
cause: e,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
Logger.info("✅ Bot stopped successfully.");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Command as command } from "#types";
|
|
2
|
+
export declare class Command extends command {
|
|
3
|
+
private static client?;
|
|
4
|
+
private static commands;
|
|
5
|
+
private static actions;
|
|
6
|
+
private static subCommands;
|
|
7
|
+
private static cooldown;
|
|
8
|
+
static initialize(): Promise<void>;
|
|
9
|
+
private static loadCommandFromDir;
|
|
10
|
+
private static buildCommandOptions;
|
|
11
|
+
private static initializeCooldown;
|
|
12
|
+
private static buildCommands;
|
|
13
|
+
private static buildSubCommandFromNameAndParent;
|
|
14
|
+
private static buildCommandFromName;
|
|
15
|
+
private static registerWithGuildID;
|
|
16
|
+
static unregisterFromName(name: string): Promise<boolean>;
|
|
17
|
+
static unregisterFromNameAndGuildID(name: string, guildID: string): Promise<boolean>;
|
|
18
|
+
static registerFromName(name: string): Promise<boolean>;
|
|
19
|
+
static registerFromNameAndGuildID(name: string, guildID: string): Promise<boolean>;
|
|
20
|
+
private static registerCommands;
|
|
21
|
+
private static isCooldownPassed;
|
|
22
|
+
private static isPrivilegeCheckPassed;
|
|
23
|
+
private static isDevCheckPassed;
|
|
24
|
+
private static replyCooldownMessage;
|
|
25
|
+
private static replyPrivilegeMessage;
|
|
26
|
+
private static replyDevMessage;
|
|
27
|
+
private static handleCommands;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/core/command.ts"],"names":[],"mappings":"AAqBA,OAAO,EAML,OAAO,IAAI,OAAO,EAGnB,MAAM,QAAQ,CAAC;AAIhB,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,CAA0D;IAChF,OAAO,CAAC,MAAM,CAAC,WAAW,CAGjB;IACT,OAAO,CAAC,MAAM,CAAC,QAAQ,CAGnB;WAEgB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;mBAiC1B,kBAAkB;IAsGvC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA0DlC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAcjC,OAAO,CAAC,MAAM,CAAC,aAAa;IAsD5B,OAAO,CAAC,MAAM,CAAC,gCAAgC;IAgC/C,OAAO,CAAC,MAAM,CAAC,oBAAoB;mBA+Cd,mBAAmB;WAqBpB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAoBlD,4BAA4B,CAC9C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;WAaC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAqBhD,0BAA0B,CAC5C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;mBA0BE,gBAAgB;IAgCrC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAkC/B,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA4BrC,OAAO,CAAC,MAAM,CAAC,gBAAgB;mBA4BV,oBAAoB;mBA4BpB,qBAAqB;mBA0BrB,eAAe;mBA4Bf,cAAc;CAmHpC"}
|