djs-builder 0.3.11 → 0.4.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/.tsbuildinfo +1 -1
- package/README.md +177 -50
- package/dist/discord/builder/components/Buttons.js +1 -0
- package/dist/discord/builder/components/Buttons.js.map +1 -1
- package/dist/discord/builder/components/Menus.js +6 -0
- package/dist/discord/builder/components/Menus.js.map +1 -1
- package/dist/discord/builder/permissions/perms.js +48 -50
- package/dist/discord/builder/permissions/perms.js.map +1 -1
- package/dist/discord/events-handler/events.js +2 -4
- package/dist/discord/events-handler/events.js.map +1 -1
- package/dist/discord/events-handler/login.d.ts.map +1 -1
- package/dist/discord/events-handler/login.js +42 -25
- package/dist/discord/events-handler/login.js.map +1 -1
- package/dist/discord/events-handler/prefix-register.d.ts +9 -1
- package/dist/discord/events-handler/prefix-register.d.ts.map +1 -1
- package/dist/discord/events-handler/prefix-register.js +21 -10
- package/dist/discord/events-handler/prefix-register.js.map +1 -1
- package/dist/discord/events-handler/prefix-responder.d.ts.map +1 -1
- package/dist/discord/events-handler/prefix-responder.js +16 -11
- package/dist/discord/events-handler/prefix-responder.js.map +1 -1
- package/dist/discord/events-handler/prefixLoader.d.ts +15 -0
- package/dist/discord/events-handler/prefixLoader.d.ts.map +1 -0
- package/dist/discord/events-handler/prefixLoader.js +97 -0
- package/dist/discord/events-handler/prefixLoader.js.map +1 -0
- package/dist/discord/events-handler/slash-register.d.ts.map +1 -1
- package/dist/discord/events-handler/slash-register.js +5 -6
- package/dist/discord/events-handler/slash-register.js.map +1 -1
- package/dist/discord/events-handler/slash-responder.js +4 -6
- package/dist/discord/events-handler/slash-responder.js.map +1 -1
- package/dist/discord/events-handler/slashLoader.d.ts +3 -0
- package/dist/discord/events-handler/slashLoader.d.ts.map +1 -0
- package/dist/discord/events-handler/slashLoader.js +88 -0
- package/dist/discord/events-handler/slashLoader.js.map +1 -0
- package/dist/discord/events-handler/starter.js +4 -5
- package/dist/discord/events-handler/starter.js.map +1 -1
- package/dist/discord/functions/anticrash.js +5 -9
- package/dist/discord/functions/anticrash.js.map +1 -1
- package/dist/discord/functions/devLogs.js +1 -2
- package/dist/discord/functions/devLogs.js.map +1 -1
- package/dist/discord/functions/mongoDb.js +2 -3
- package/dist/discord/functions/mongoDb.js.map +1 -1
- package/dist/discord/functions/similarity.js +1 -2
- package/dist/discord/functions/similarity.js.map +1 -1
- package/dist/discord/functions/terminal.js +8 -10
- package/dist/discord/functions/terminal.js.map +1 -1
- package/dist/discord/functions/versedb.js +2 -4
- package/dist/discord/functions/versedb.js.map +1 -1
- package/dist/discord/types/starter.d.ts +2 -1
- package/dist/discord/types/starter.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/lib/discord/events-handler/login.ts +16 -2
- package/lib/discord/events-handler/prefix-register.ts +22 -10
- package/lib/discord/events-handler/prefix-responder.ts +9 -1
- package/lib/discord/events-handler/prefixLoader.ts +76 -0
- package/lib/discord/events-handler/slash-register.ts +1 -0
- package/lib/discord/events-handler/slashLoader.ts +83 -0
- package/lib/discord/events-handler/starter.ts +1 -1
- package/lib/discord/types/starter.ts +6 -4
- package/lib/index.ts +0 -4
- package/package.json +3 -3
- package/tsconfig.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"similarity.js","sourceRoot":"","sources":["../../../lib/discord/functions/similarity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"similarity.js","sourceRoot":"","sources":["../../../lib/discord/functions/similarity.ts"],"names":[],"mappings":";;AAEA,gDAcC;AAdD,SAAgB,kBAAkB,CAAC,WAAmB,EAAE,QAAqC;IACzF,MAAM,mBAAmB,GAAG,GAAG,CAAC;IAChC,MAAM,eAAe,GAA2C,EAAE,CAAC;IAEnE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;QAC5B,MAAM,UAAU,GAAG,m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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CACnB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EACpB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EACpB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAC9B,CAAC;QACN,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.terminalLogs =
|
|
6
|
+
exports.terminalLogs = terminalLogs;
|
|
7
7
|
const colorette_1 = require("colorette");
|
|
8
8
|
const cli_table_1 = __importDefault(require("cli-table"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
async function terminalLogs(client, bot) {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
13
12
|
const { user, prefixSize = 0, slashSize = 0, eventSize = 0 } = client;
|
|
14
13
|
const totalCommands = slashSize + prefixSize;
|
|
15
14
|
const totalGuilds = client.guilds.cache.size;
|
|
@@ -46,27 +45,27 @@ async function terminalLogs(client, bot) {
|
|
|
46
45
|
head: [(0, colorette_1.blue)('# Bot Info')],
|
|
47
46
|
colWidths: [30, 25]
|
|
48
47
|
});
|
|
49
|
-
if (
|
|
48
|
+
if (client.presence?.Status) {
|
|
50
49
|
botInfoTable.push([(0, colorette_1.yellow)('Status'), client.presence.Status]);
|
|
51
50
|
}
|
|
52
|
-
if (
|
|
51
|
+
if (bot.Status?.activities && bot.Status.activities.length > 0) {
|
|
53
52
|
botInfoTable.push([(0, colorette_1.cyanBright)('Activity'), bot.Status.activities[0]]);
|
|
54
53
|
}
|
|
55
|
-
if (
|
|
54
|
+
if (bot.BotInfo?.botInvite) {
|
|
56
55
|
botInfoTable.push([(0, colorette_1.cyanBright)('Bot Invite'), bot.BotInfo.botInvite]);
|
|
57
56
|
}
|
|
58
57
|
botInfoTable.push([(0, colorette_1.red)('Guilds Count'), totalGuilds], [(0, colorette_1.redBright)('Members Count'), totalMembers]);
|
|
59
|
-
if (
|
|
58
|
+
if (bot.Database?.verse) {
|
|
60
59
|
botInfoTable.push([(0, colorette_1.gray)('Bot Database'), 'VerseDb']);
|
|
61
60
|
}
|
|
62
|
-
else if (
|
|
61
|
+
else if (bot.Database?.mongo) {
|
|
63
62
|
botInfoTable.push([(0, colorette_1.greenBright)('Bot Database'), 'MongoDb']);
|
|
64
63
|
}
|
|
65
64
|
botInfoTable.push([(0, colorette_1.redBright)('Bot Size'), `${(projectSize / (1024 * 1024)).toFixed(2)} MB`]);
|
|
66
|
-
if (
|
|
65
|
+
if (client.user?.displayAvatarURL()) {
|
|
67
66
|
botInfoTable.push([(0, colorette_1.blueBright)('AvatarURL'), client.user.displayAvatarURL()]);
|
|
68
67
|
}
|
|
69
|
-
if (
|
|
68
|
+
if (bot.BotInfo?.ownerId) {
|
|
70
69
|
botInfoTable.push([(0, colorette_1.cyan)('Owner'), bot.BotInfo.ownerId]);
|
|
71
70
|
}
|
|
72
71
|
if (client.readyTimestamp) {
|
|
@@ -76,5 +75,4 @@ async function terminalLogs(client, bot) {
|
|
|
76
75
|
console.log(botStatesTable.toString());
|
|
77
76
|
console.log(botInfoTable.toString());
|
|
78
77
|
}
|
|
79
|
-
exports.terminalLogs = terminalLogs;
|
|
80
78
|
//# sourceMappingURL=terminal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../../lib/discord/functions/terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../../lib/discord/functions/terminal.ts"],"names":[],"mappings":";;;;;AAaA,oCAiFC;AA9FD,yCAAuI;AAEvI,0DAA8B;AAC9B,4CAAoB;AACpB,gDAAwB;AASjB,KAAK,UAAU,YAAY,CAAC,MAAW,EAAE,GAAe;IAC3D,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC;IAEtE,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,KAAU,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEtG,SAAS,cAAc,CAAC,GAAW;QAC/B,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAE3D,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBACrD,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;Y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C,UAAU,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7F,IAAI,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,CAAC;QAClC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAA,sBAAU,EAAC,WAAW,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACvB,YAAY,CAAC,IAAI,CAAC,CAAC,IAAA,gBAAI,EAAC,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,cAAc,EAAE,CAAC;QACpE,YAAY,CAAC,IAAI,CAAC,CAAC,IAAA,wBAAY,EAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -3,14 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.verseConnect =
|
|
6
|
+
exports.verseConnect = verseConnect;
|
|
7
7
|
const verse_db_1 = __importDefault(require("verse.db"));
|
|
8
8
|
async function verseConnect(options) {
|
|
9
|
-
var _a, _b;
|
|
10
9
|
const connection = {
|
|
11
10
|
adapter: options.adapterType,
|
|
12
11
|
dataPath: options.path,
|
|
13
|
-
secure: { enable:
|
|
12
|
+
secure: { enable: options.secure?.enable, secret: options.secure?.secret || 'djs-builder' },
|
|
14
13
|
devLogs: {
|
|
15
14
|
enable: options.dev.enable,
|
|
16
15
|
path: options.dev.logsPath || ''
|
|
@@ -19,5 +18,4 @@ async function verseConnect(options) {
|
|
|
19
18
|
const db = new verse_db_1.default.connect(connection);
|
|
20
19
|
return db;
|
|
21
20
|
}
|
|
22
|
-
exports.verseConnect = verseConnect;
|
|
23
21
|
//# sourceMappingURL=versedb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versedb.js","sourceRoot":"","sources":["../../../lib/discord/functions/versedb.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"versedb.js","sourceRoot":"","sources":["../../../lib/discord/functions/versedb.ts"],"names":[],"mappings":";;;;;AAGA,oCAaC;AAhBD,wDAA+B;AAGxB,KAAK,UAAU,YAAY,CAAC,OAAgB;IAC/C,MAAM,UAAU,GAAG;QACf,OAAO,EAAE,OAAO,CAAC,WAAW;QAC5B,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,aAAa,EAAE;QAC3F,OAAO,EAAE;YACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;YAC1B,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE;SACnC;KACJ,CAAC;IAEF,MAAM,EAAE,GAAG,IAAI,kBAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC1C,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Client } from 'discord.js';
|
|
3
2
|
export interface BotOptions {
|
|
4
3
|
token?: string;
|
|
@@ -21,6 +20,7 @@ export interface BotOptions {
|
|
|
21
20
|
serverInvite?: string;
|
|
22
21
|
ownerId?: string;
|
|
23
22
|
partners?: string[];
|
|
23
|
+
developers?: string[];
|
|
24
24
|
};
|
|
25
25
|
Status?: {
|
|
26
26
|
state: 'online' | 'dnd' | 'idle' | 'invisible' | 'Streaming' | any;
|
|
@@ -91,6 +91,7 @@ export interface Command {
|
|
|
91
91
|
aliases?: string[];
|
|
92
92
|
cooldown?: number;
|
|
93
93
|
usage?: string;
|
|
94
|
+
developer?: boolean;
|
|
94
95
|
prefix?: boolean;
|
|
95
96
|
category?: string;
|
|
96
97
|
owner?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starter.d.ts","sourceRoot":"","sources":["../../../lib/discord/types/starter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"starter.d.ts","sourceRoot":"","sources":["../../../lib/discord/types/starter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,MAAM,WAAW,UAAU;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACH,OAAO,CAAC,EAAE;YACN,MAAM,EAAE,OAAO,CAAA;YACf,WAAW,EAAE,GAAG,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,OAAO,CAAC,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,QAAQ,CAAC,EAAE,OAAO,CAAA;KACrB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QACN,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAA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C;CACnB;AAED,MAAM,WAAW,cAAc;IAC3B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAC7D"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;;;;;;;AAClE,wBAA0E"}
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PermissionChecker = exports.MenuManager = exports.ButtonManager = exports.Starter = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const RED = "\x1b[31m";
|
|
10
|
-
const CYAN = "\x1b[36m";
|
|
11
|
-
const RESET = "\x1b[0m";
|
|
12
9
|
const packageJsonPath = path_1.default.resolve(process.cwd(), "package.json");
|
|
13
10
|
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
14
11
|
const getLibraryVersion = function (library) {
|
|
@@ -25,8 +22,7 @@ fetch("https://registry.npmjs.com/-/v1/search?text=djs-builder")
|
|
|
25
22
|
return response.json();
|
|
26
23
|
})
|
|
27
24
|
.then(data => {
|
|
28
|
-
|
|
29
|
-
const version = (_b = (_a = data.objects[0]) === null || _a === void 0 ? void 0 : _a.package) === null || _b === void 0 ? void 0 : _b.version;
|
|
25
|
+
const version = data.objects[0]?.package?.version;
|
|
30
26
|
if (version && getLibraryVersion("djs-builder") !== version) {
|
|
31
27
|
console.error("Error: Please update djs-builder to the latest version (" + version + ").");
|
|
32
28
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,eAAe,GAAW,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;AAC5E,MAAM,WAAW,GAAQ,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E,MAAM,iBAAiB,GAAG,UAAS,OAAY;IAC3C,MAAM,YAAY,GAAG,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC;IACpD,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,IAAI,EAAE,CAAC;IAC1D,MAAM,OAAO,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC;IACpH,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,KAAK,CAAC,yDAAyD,CAAC;KAC3D,IAAI,CAAC,QAAQ,CAAC,EAAE;IACb,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;KACD,IAAI,CAAC,IAAI,CAAC,EAAE;IACT,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;IAClD,IAAI,OAAO,IAAI,iBAAiB,CAAC,aAAa,CAAC,KAAK,OAAO,EAAE,CAAC;QAC1D,OAAO,CAAC,KAAK,CAAC,0DAA0D,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;IAC/F,CAAC;AACL,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;AAG3B,2CAAyF;AAEhF,wFAFA,eAAO,OAEA;AAAE,8FAFA,qBAAa,OAEA;AAAE,4FAFA,mBAAW,OAEA;AAAE,kGAFA,yBAAiB,OAEA;AAC/D,kBAAe,EAAE,OAAO,EAAP,eAAO,EAAE,aAAa,EAAb,qBAAa,EAAE,WAAW,EAAX,mBAAW,EAAE,iBAAiB,EAAjB,yBAAiB,EAAE,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { loadPrefix } from './prefix-responder';
|
|
|
4
4
|
import { loadSlash } from './slash-responder';
|
|
5
5
|
import { readCommands } from './prefix-register';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
-
|
|
7
|
+
import fs from 'fs';
|
|
8
8
|
export async function login(djs: Client, options: StarterOptions) {
|
|
9
9
|
|
|
10
10
|
const botData = new Collection<string, string | string[]>();
|
|
@@ -27,8 +27,11 @@ export async function login(djs: Client, options: StarterOptions) {
|
|
|
27
27
|
await djs.user?.setAvatar(avatarPath);
|
|
28
28
|
}
|
|
29
29
|
if (options.bot.banner) {
|
|
30
|
+
const fileBuffer = fs.readFileSync(path.join(process.cwd(), options.bot.banner));
|
|
31
|
+
const base64String = fileBuffer.toString('base64');
|
|
32
|
+
|
|
30
33
|
await djs.rest.patch(Routes.user(), {
|
|
31
|
-
body: { banner: await resolveImage(
|
|
34
|
+
body: { banner: await resolveImage(base64String) }
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -50,14 +53,25 @@ export async function login(djs: Client, options: StarterOptions) {
|
|
|
50
53
|
if (options.bot.BotInfo && options.bot.BotInfo.serverInvite) {
|
|
51
54
|
botData.set('serverInvite', options.bot.BotInfo.serverInvite);
|
|
52
55
|
}
|
|
56
|
+
if (options.bot.BotInfo && options.bot.BotInfo.developers) {
|
|
57
|
+
botData.set('developers', options.bot.BotInfo.developers);
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
|
|
55
61
|
if (options.prefix) {
|
|
56
62
|
await readCommands(djs, options.prefix)
|
|
57
63
|
await loadPrefix(djs, options.prefix);
|
|
64
|
+
if (options.prefix.path) botData.set('prefixPath', options.prefix.path);
|
|
65
|
+
|
|
58
66
|
}
|
|
59
67
|
if (options.slash && options.bot.token) {
|
|
60
68
|
await loadSlash(djs, options.bot?.token, options.slash);
|
|
69
|
+
botData.set('slashCommands', options.slash.path);
|
|
70
|
+
if (options.slash.serverId) botData.set('serverIdSlash', options.slash.serverId);
|
|
71
|
+
if (options.slash.global === true) botData.set('globalSlash', 'true');
|
|
72
|
+
if (options.slash.global === false) botData.set('globalSlash', 'false');
|
|
73
|
+
if (options.bot?.token) botData.set('botToken', options.bot.token);
|
|
74
|
+
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
|
|
@@ -7,8 +7,8 @@ export const commands = new Collection<string, Command>();
|
|
|
7
7
|
export const aliases = new Collection<string, string>();
|
|
8
8
|
export const commandNames = new Set<string>();
|
|
9
9
|
|
|
10
|
-
export async function readCommands(client: any, prefix: { path: string }): Promise<number
|
|
11
|
-
|
|
10
|
+
export async function readCommands(client: any, prefix: { path: string }): Promise<Array<{ name: string; usage: string | undefined; description: string | undefined; aliases: string[] | undefined; cooldown: number | undefined; developer: boolean | undefined; owner: boolean | undefined }>> {
|
|
11
|
+
const commandDetails: Array<{ name: string; usage: string | undefined; description: string | undefined; aliases: string[] | undefined; cooldown: number | undefined; developer: boolean | undefined; owner: boolean | undefined }> = [];
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
14
|
const resolvedPath = resolve(process.cwd(), prefix.path);
|
|
@@ -19,7 +19,8 @@ export async function readCommands(client: any, prefix: { path: string }): Promi
|
|
|
19
19
|
const filePath = join(resolvedPath, file.name);
|
|
20
20
|
|
|
21
21
|
if (file.isDirectory()) {
|
|
22
|
-
|
|
22
|
+
const subCommandDetails = await readCommands(client, { path: filePath });
|
|
23
|
+
commandDetails.push(...subCommandDetails);
|
|
23
24
|
} else if (file.isFile()) {
|
|
24
25
|
try {
|
|
25
26
|
const commandModule = await import(filePath);
|
|
@@ -28,9 +29,10 @@ export async function readCommands(client: any, prefix: { path: string }): Promi
|
|
|
28
29
|
if (command && (command.execute || command.run)) {
|
|
29
30
|
const defaultCommand: Command = {
|
|
30
31
|
description: "No description provided.",
|
|
31
|
-
cooldown:
|
|
32
|
+
cooldown: undefined,
|
|
32
33
|
usage: "No usage information provided.",
|
|
33
|
-
|
|
34
|
+
aliases: [],
|
|
35
|
+
developer: false,
|
|
34
36
|
owner: false,
|
|
35
37
|
...command
|
|
36
38
|
};
|
|
@@ -45,7 +47,15 @@ export async function readCommands(client: any, prefix: { path: string }): Promi
|
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
commandDetails.push({
|
|
51
|
+
name: defaultCommand.name,
|
|
52
|
+
usage: defaultCommand.usage || 'No usage information provided.',
|
|
53
|
+
description: defaultCommand.description || 'No description provided.',
|
|
54
|
+
aliases: defaultCommand.aliases || [],
|
|
55
|
+
cooldown: defaultCommand.cooldown,
|
|
56
|
+
developer: defaultCommand.developer,
|
|
57
|
+
owner: defaultCommand.owner,
|
|
58
|
+
});
|
|
49
59
|
}
|
|
50
60
|
} catch (error: any) {
|
|
51
61
|
console.error(`Error in file: ${filePath}`);
|
|
@@ -53,11 +63,13 @@ export async function readCommands(client: any, prefix: { path: string }): Promi
|
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
|
|
67
|
+
client.prefixCommands = commandDetails;
|
|
68
|
+
client.prefixSize = commandDetails.length;
|
|
69
|
+
return commandDetails;
|
|
58
70
|
} catch (error: any) {
|
|
59
71
|
console.error(`⚠️ Error reading directory: ${prefix.path}`);
|
|
60
72
|
console.error(error.message);
|
|
61
|
-
return
|
|
73
|
+
return [];
|
|
62
74
|
}
|
|
63
|
-
}
|
|
75
|
+
}
|
|
@@ -8,12 +8,13 @@ const cooldowns: Collection<string, Collection<string, number>> = new Collection
|
|
|
8
8
|
|
|
9
9
|
async function handleMessageCreate(message: Message, prefix: PrefixOptions): Promise<void> {
|
|
10
10
|
const botPrefix = prefix.prefix || '!';
|
|
11
|
+
const developers = botData.get('developers') as string[] | undefined;
|
|
11
12
|
|
|
12
13
|
if (message.guild?.members.me) {
|
|
13
14
|
const user = message.author;
|
|
14
15
|
const botData = new Collection<string, string | string[]>();
|
|
15
16
|
const permissionsArray = botData.get('permissions') as string[] | undefined;
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
if (!message.guild.members.me.permissions.has('SendMessages')) {
|
|
18
19
|
try {
|
|
19
20
|
user.send({ content:"I'm sorry, but I don't have permission to send messages in this server."});
|
|
@@ -67,6 +68,13 @@ async function handleMessageCreate(message: Message, prefix: PrefixOptions): Pro
|
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
if (!developers || !developers.includes(message.author.id)) {
|
|
72
|
+
if (message.author.id === ownerId) return;
|
|
73
|
+
await message.reply("You are not authorized to use this command.");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
70
78
|
const now = Date.now();
|
|
71
79
|
const timestamps = cooldowns.get(command.name) || new Collection<string, number>();
|
|
72
80
|
const cooldownAmount = (command.cooldown || 3) * 1000;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Collection } from 'discord.js';
|
|
2
|
+
import { promises as fsPromises } from 'fs';
|
|
3
|
+
import { join, resolve } from 'path';
|
|
4
|
+
import { Command } from '../types/utils';
|
|
5
|
+
|
|
6
|
+
export const commands = new Collection<string, Command>();
|
|
7
|
+
export const aliases = new Collection<string, string>();
|
|
8
|
+
export const commandNames = new Set<string>();
|
|
9
|
+
|
|
10
|
+
export async function prefixLoader(client: any): Promise<Array<{ name: string; usage: string | undefined; description: string | undefined; aliases: string[] | undefined; cooldown: number | undefined; developer: boolean | undefined; owner: boolean | undefined }>> {
|
|
11
|
+
const commandDetails: Array<{ name: string; usage: string | undefined; description: string | undefined; aliases: string[] | undefined; cooldown: number | undefined; developer: boolean | undefined; owner: boolean | undefined }> = [];
|
|
12
|
+
const botData = new Collection<string, string | string[]>();
|
|
13
|
+
const prefixPath = botData.get('prefixPath') as string;
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const resolvedPath = resolve(process.cwd(), prefixPath);
|
|
17
|
+
await fsPromises.access(resolvedPath);
|
|
18
|
+
const files = await fsPromises.readdir(resolvedPath, { withFileTypes: true });
|
|
19
|
+
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const filePath = join(resolvedPath, file.name);
|
|
22
|
+
|
|
23
|
+
if (file.isDirectory()) {
|
|
24
|
+
const subCommandDetails = await prefixLoader(client);
|
|
25
|
+
commandDetails.push(...subCommandDetails);
|
|
26
|
+
} else if (file.isFile()) {
|
|
27
|
+
try {
|
|
28
|
+
const commandModule = await import(filePath);
|
|
29
|
+
const command: Command = commandModule.default || commandModule;
|
|
30
|
+
|
|
31
|
+
if (command && (command.execute || command.run)) {
|
|
32
|
+
const defaultCommand: Command = {
|
|
33
|
+
description: "No description provided.",
|
|
34
|
+
cooldown: undefined,
|
|
35
|
+
usage: "No usage information provided.",
|
|
36
|
+
aliases: [],
|
|
37
|
+
developer: false,
|
|
38
|
+
owner: false,
|
|
39
|
+
...command
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
commands.set(defaultCommand.name, defaultCommand);
|
|
43
|
+
commandNames.add(defaultCommand.name);
|
|
44
|
+
|
|
45
|
+
if (defaultCommand.aliases && Array.isArray(defaultCommand.aliases)) {
|
|
46
|
+
defaultCommand.aliases.forEach(alias => {
|
|
47
|
+
aliases.set(alias, defaultCommand.name);
|
|
48
|
+
commandNames.add(alias);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
commandDetails.push({
|
|
53
|
+
name: defaultCommand.name,
|
|
54
|
+
usage: defaultCommand.usage || 'No usage information provided.',
|
|
55
|
+
description: defaultCommand.description || 'No description provided.',
|
|
56
|
+
aliases: defaultCommand.aliases || [],
|
|
57
|
+
cooldown: defaultCommand.cooldown,
|
|
58
|
+
developer: defaultCommand.developer,
|
|
59
|
+
owner: defaultCommand.owner,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
} catch (error: any) {
|
|
63
|
+
console.error(`Error in file: ${filePath}`);
|
|
64
|
+
console.error(error.message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
client.prefixCommands = commandDetails;
|
|
69
|
+
client.prefixSize = commandDetails.length;
|
|
70
|
+
return commandDetails;
|
|
71
|
+
} catch (error: any) {
|
|
72
|
+
console.error(`⚠️ Error reading directory: ${prefixPath}`);
|
|
73
|
+
console.error(error.message);
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -72,6 +72,7 @@ export async function registerSlashCommands(client: any, token: string, slash: S
|
|
|
72
72
|
console.error('⚠️ Error registering slash commands:', error.message);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
client.slashCommands = slashCommands;
|
|
75
76
|
client.slashSize = slashCommands.size;
|
|
76
77
|
return slashCommands;
|
|
77
78
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Collection, Guild } from 'discord.js';
|
|
2
|
+
import { REST } from '@discordjs/rest';
|
|
3
|
+
import { Routes } from 'discord-api-types/v10';
|
|
4
|
+
import { readdir } from 'fs/promises';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
export async function slashLoader(client: any): Promise<Collection<string, any>> {
|
|
7
|
+
const botData = new Collection<string, string | string[]>();
|
|
8
|
+
|
|
9
|
+
const slashCommandsPath = botData.get('slashCommands') as string;
|
|
10
|
+
const serverIdSlash = botData.get('serverIdSlash') as string;
|
|
11
|
+
const globalSlash = botData.get('globalSlash') as string;
|
|
12
|
+
const botToken = botData.get('botToken') as string;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if (!botToken) {
|
|
16
|
+
throw new Error("⚠️ \x1b[33m%sPlease provide valid bot token to register slash commands.\x1b[0m");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const slashCommands = new Collection<string, any>();
|
|
20
|
+
const rest = new REST({ version: '10' }).setToken(botToken);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const resolvedPath = path.join(process.cwd(), slashCommandsPath);
|
|
24
|
+
const dirents = await readdir(resolvedPath, { withFileTypes: true });
|
|
25
|
+
|
|
26
|
+
for (const dirent of dirents) {
|
|
27
|
+
if (dirent.isDirectory()) {
|
|
28
|
+
const folderPath = path.join(resolvedPath, dirent.name);
|
|
29
|
+
const files = await readdir(folderPath);
|
|
30
|
+
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
try {
|
|
33
|
+
const command = require(path.join(folderPath, file));
|
|
34
|
+
if (command.data) {
|
|
35
|
+
if (command.cooldown && !isNaN(command.cooldown)) {
|
|
36
|
+
command.data.cooldown = command.cooldown || 0;
|
|
37
|
+
}
|
|
38
|
+
slashCommands.set(command.data.name, command);
|
|
39
|
+
}
|
|
40
|
+
} catch (error: any) {
|
|
41
|
+
console.error(`⚠️ Error in file: ${path.join(folderPath, file)}`);
|
|
42
|
+
console.error(error.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
try {
|
|
47
|
+
const command = require(path.join(resolvedPath, dirent.name));
|
|
48
|
+
if (command.data) {
|
|
49
|
+
if (command.cooldown && !isNaN(command.cooldown)) {
|
|
50
|
+
command.data.cooldown = command.cooldown || 0;
|
|
51
|
+
}
|
|
52
|
+
slashCommands.set(command.data.name, command);
|
|
53
|
+
}
|
|
54
|
+
} catch (error: any) {
|
|
55
|
+
console.error(`⚠️ Error in file: ${path.join(resolvedPath, dirent.name)}`);
|
|
56
|
+
console.error(error.message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (globalSlash === 'true' && !serverIdSlash) {
|
|
62
|
+
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
63
|
+
await rest.put(Routes.applicationCommands((client.user?.id || '')), { body: slashCommandArray, headers: { Authorization: `Bot ${botToken}` } });
|
|
64
|
+
} else if (globalSlash === 'false' && serverIdSlash) {
|
|
65
|
+
const guild = client.guilds.cache.get(serverIdSlash) as Guild | undefined;
|
|
66
|
+
if (guild) {
|
|
67
|
+
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
68
|
+
await rest.put(Routes.applicationGuildCommands((client.user?.id || ''), guild.id), { body: slashCommandArray, headers: { Authorization: `Bot ${botToken}` } });
|
|
69
|
+
} else {
|
|
70
|
+
console.error(`⚠️ Guild with ID ${serverIdSlash} not found.`);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
74
|
+
await rest.put(Routes.applicationCommands((client.user?.id || '')), { body: slashCommandArray, headers: { Authorization: `Bot ${botToken}` } });
|
|
75
|
+
}
|
|
76
|
+
} catch (error: any) {
|
|
77
|
+
console.error('⚠️ Error registering slash commands:', error.message);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
client.slashCommands = slashCommands;
|
|
81
|
+
client.slashSize = slashCommands.size;
|
|
82
|
+
return slashCommands;
|
|
83
|
+
}
|
|
@@ -11,7 +11,7 @@ export class Starter implements StarterInterface {
|
|
|
11
11
|
|
|
12
12
|
try {
|
|
13
13
|
if (options.bot?.Database?.mongo) {
|
|
14
|
-
await mongoConnect(options.bot.Database.mongo.mongoURI, options.bot.Database.mongo.dbName || '
|
|
14
|
+
await mongoConnect(options.bot.Database.mongo.mongoURI, options.bot.Database.mongo.dbName || 'djsbuilder');
|
|
15
15
|
mongoDb = await getDb();
|
|
16
16
|
}
|
|
17
17
|
if (options.bot?.Database?.verse) {
|
|
@@ -16,11 +16,12 @@ export interface BotOptions {
|
|
|
16
16
|
banner?: string;
|
|
17
17
|
BotInfo?: {
|
|
18
18
|
perms?: string[];
|
|
19
|
-
serverId?: string
|
|
20
|
-
botInvite?: string
|
|
21
|
-
serverInvite?: string
|
|
22
|
-
ownerId?: string
|
|
19
|
+
serverId?: string;
|
|
20
|
+
botInvite?: string;
|
|
21
|
+
serverInvite?: string;
|
|
22
|
+
ownerId?: string;
|
|
23
23
|
partners?: string[];
|
|
24
|
+
developers?: string[];
|
|
24
25
|
};
|
|
25
26
|
Status?: {
|
|
26
27
|
state: 'online' | 'dnd' | 'idle' | 'invisible' | 'Streaming' | any;
|
|
@@ -100,6 +101,7 @@ export interface Command {
|
|
|
100
101
|
aliases?: string[];
|
|
101
102
|
cooldown?: number;
|
|
102
103
|
usage?: string;
|
|
104
|
+
developer?: boolean;
|
|
103
105
|
prefix?: boolean;
|
|
104
106
|
category?: string;
|
|
105
107
|
owner?: boolean;
|
package/lib/index.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
|
|
4
|
-
const RED: string = "\x1b[31m";
|
|
5
|
-
const CYAN: string = "\x1b[36m";
|
|
6
|
-
const RESET: string = "\x1b[0m";
|
|
7
|
-
|
|
8
4
|
const packageJsonPath: string = path.resolve(process.cwd(), "package.json");
|
|
9
5
|
const packageJson: any = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
10
6
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "djs-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Discord.js bot builder. Supports Ts and Js.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "ts-node lib/index.ts",
|
|
9
9
|
"start": "node dist/index.js",
|
|
10
|
-
"build": "tsc"
|
|
10
|
+
"build": "tsc --build --force"
|
|
11
11
|
},
|
|
12
12
|
"author": "zenith-79",
|
|
13
13
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"cli-table": "^0.3.11",
|
|
34
34
|
"colorette": "^2.0.20",
|
|
35
|
-
"discord.js": "^14.15.
|
|
35
|
+
"discord.js": "^14.15.3",
|
|
36
36
|
"mongodb": "^6.5.0",
|
|
37
37
|
"verse.db": "^2.0.4"
|
|
38
38
|
},
|