djs-builder 0.3.12 → 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/dist/discord/events-handler/login.d.ts.map +1 -1
- package/dist/discord/events-handler/login.js +21 -1
- 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 +19 -8
- 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 +7 -0
- 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 +1 -0
- package/dist/discord/events-handler/slash-register.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 +1 -1
- package/dist/discord/types/starter.d.ts +2 -0
- package/dist/discord/types/starter.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- 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/package.json +2 -2
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.commandNames = exports.aliases = exports.commands = void 0;
|
|
27
|
+
exports.prefixLoader = prefixLoader;
|
|
28
|
+
const discord_js_1 = require("discord.js");
|
|
29
|
+
const fs_1 = require("fs");
|
|
30
|
+
const path_1 = require("path");
|
|
31
|
+
exports.commands = new discord_js_1.Collection();
|
|
32
|
+
exports.aliases = new discord_js_1.Collection();
|
|
33
|
+
exports.commandNames = new Set();
|
|
34
|
+
async function prefixLoader(client) {
|
|
35
|
+
const commandDetails = [];
|
|
36
|
+
const botData = new discord_js_1.Collection();
|
|
37
|
+
const prefixPath = botData.get('prefixPath');
|
|
38
|
+
try {
|
|
39
|
+
const resolvedPath = (0, path_1.resolve)(process.cwd(), prefixPath);
|
|
40
|
+
await fs_1.promises.access(resolvedPath);
|
|
41
|
+
const files = await fs_1.promises.readdir(resolvedPath, { withFileTypes: true });
|
|
42
|
+
for (const file of files) {
|
|
43
|
+
const filePath = (0, path_1.join)(resolvedPath, file.name);
|
|
44
|
+
if (file.isDirectory()) {
|
|
45
|
+
const subCommandDetails = await prefixLoader(client);
|
|
46
|
+
commandDetails.push(...subCommandDetails);
|
|
47
|
+
}
|
|
48
|
+
else if (file.isFile()) {
|
|
49
|
+
try {
|
|
50
|
+
const commandModule = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s)));
|
|
51
|
+
const command = commandModule.default || commandModule;
|
|
52
|
+
if (command && (command.execute || command.run)) {
|
|
53
|
+
const defaultCommand = {
|
|
54
|
+
description: "No description provided.",
|
|
55
|
+
cooldown: undefined,
|
|
56
|
+
usage: "No usage information provided.",
|
|
57
|
+
aliases: [],
|
|
58
|
+
developer: false,
|
|
59
|
+
owner: false,
|
|
60
|
+
...command
|
|
61
|
+
};
|
|
62
|
+
exports.commands.set(defaultCommand.name, defaultCommand);
|
|
63
|
+
exports.commandNames.add(defaultCommand.name);
|
|
64
|
+
if (defaultCommand.aliases && Array.isArray(defaultCommand.aliases)) {
|
|
65
|
+
defaultCommand.aliases.forEach(alias => {
|
|
66
|
+
exports.aliases.set(alias, defaultCommand.name);
|
|
67
|
+
exports.commandNames.add(alias);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
commandDetails.push({
|
|
71
|
+
name: defaultCommand.name,
|
|
72
|
+
usage: defaultCommand.usage || 'No usage information provided.',
|
|
73
|
+
description: defaultCommand.description || 'No description provided.',
|
|
74
|
+
aliases: defaultCommand.aliases || [],
|
|
75
|
+
cooldown: defaultCommand.cooldown,
|
|
76
|
+
developer: defaultCommand.developer,
|
|
77
|
+
owner: defaultCommand.owner,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error(`Error in file: ${filePath}`);
|
|
83
|
+
console.error(error.message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
client.prefixCommands = commandDetails;
|
|
88
|
+
client.prefixSize = commandDetails.length;
|
|
89
|
+
return commandDetails;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.error(`⚠️ Error reading directory: ${prefixPath}`);
|
|
93
|
+
console.error(error.message);
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=prefixLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefixLoader.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/prefixLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASA,oCAkEC;AA3ED,2CAAwC;AACxC,2BAA4C;AAC5C,+BAAqC;AAGxB,QAAA,QAAQ,GAAG,IAAI,uBAAU,EAAmB,CAAC;AAC7C,QAAA,OAAO,GAAG,IAAI,uBAAU,EAAkB,CAAC;AAC3C,QAAA,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AAEvC,KAAK,UAAU,YAAY,CAAC,MAAW;IAC1C,MAAM,cAAc,GAAiN,EAAE,CAAC;IACxO,MAAM,OAAO,GAAG,IAAI,uBAAU,EAA6B,CAAC;IAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAW,CAAC;IAEvD,IAAI,CAAC;QACD,MAAM,YAAY,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACxD,MAAM,aAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtC,MAAM,KAAK,GAAG,MAAM,aAAU,CA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;AAEhD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"slash-register.d.ts","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAS,MAAM,YAAY,CAAC;AAK/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAsE7H"}
|
|
@@ -76,6 +76,7 @@ async function registerSlashCommands(client, token, slash) {
|
|
|
76
76
|
catch (error) {
|
|
77
77
|
console.error('⚠️ Error registering slash commands:', error.message);
|
|
78
78
|
}
|
|
79
|
+
client.slashCommands = slashCommands;
|
|
79
80
|
client.slashSize = slashCommands.size;
|
|
80
81
|
return slashCommands;
|
|
81
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slash-register.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-register.ts"],"names":[],"mappings":";;;;;AAOA,
|
|
1
|
+
{"version":3,"file":"slash-register.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-register.ts"],"names":[],"mappings":";;;;;AAOA,sDAsEC;AA7ED,2CAA+C;AAC/C,0CAAuC;AACvC,+CAA+C;AAC/C,0CAAsC;AACtC,gDAAwB;AAGjB,KAAK,UAAU,qBAAqB,CAAC,MAAW,EAAE,KAAa,EAAE,KAAmB;IAEvF,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,aAAa,GA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EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACjJ,CAAC;IACL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,MAAM,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;IACtC,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slashLoader.d.ts","sourceRoot":"","sources":["../../../lib/discord/events-handler/slashLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAS,MAAM,YAAY,CAAC;AAK/C,wBAAsB,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CA6E/E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.slashLoader = slashLoader;
|
|
7
|
+
const discord_js_1 = require("discord.js");
|
|
8
|
+
const rest_1 = require("@discordjs/rest");
|
|
9
|
+
const v10_1 = require("discord-api-types/v10");
|
|
10
|
+
const promises_1 = require("fs/promises");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
async function slashLoader(client) {
|
|
13
|
+
const botData = new discord_js_1.Collection();
|
|
14
|
+
const slashCommandsPath = botData.get('slashCommands');
|
|
15
|
+
const serverIdSlash = botData.get('serverIdSlash');
|
|
16
|
+
const globalSlash = botData.get('globalSlash');
|
|
17
|
+
const botToken = botData.get('botToken');
|
|
18
|
+
if (!botToken) {
|
|
19
|
+
throw new Error("⚠️ \x1b[33m%sPlease provide valid bot token to register slash commands.\x1b[0m");
|
|
20
|
+
}
|
|
21
|
+
const slashCommands = new discord_js_1.Collection();
|
|
22
|
+
const rest = new rest_1.REST({ version: '10' }).setToken(botToken);
|
|
23
|
+
try {
|
|
24
|
+
const resolvedPath = path_1.default.join(process.cwd(), slashCommandsPath);
|
|
25
|
+
const dirents = await (0, promises_1.readdir)(resolvedPath, { withFileTypes: true });
|
|
26
|
+
for (const dirent of dirents) {
|
|
27
|
+
if (dirent.isDirectory()) {
|
|
28
|
+
const folderPath = path_1.default.join(resolvedPath, dirent.name);
|
|
29
|
+
const files = await (0, promises_1.readdir)(folderPath);
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
try {
|
|
32
|
+
const command = require(path_1.default.join(folderPath, file));
|
|
33
|
+
if (command.data) {
|
|
34
|
+
if (command.cooldown && !isNaN(command.cooldown)) {
|
|
35
|
+
command.data.cooldown = command.cooldown || 0;
|
|
36
|
+
}
|
|
37
|
+
slashCommands.set(command.data.name, command);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error(`⚠️ Error in file: ${path_1.default.join(folderPath, file)}`);
|
|
42
|
+
console.error(error.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
try {
|
|
48
|
+
const command = require(path_1.default.join(resolvedPath, dirent.name));
|
|
49
|
+
if (command.data) {
|
|
50
|
+
if (command.cooldown && !isNaN(command.cooldown)) {
|
|
51
|
+
command.data.cooldown = command.cooldown || 0;
|
|
52
|
+
}
|
|
53
|
+
slashCommands.set(command.data.name, command);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error(`⚠️ Error in file: ${path_1.default.join(resolvedPath, dirent.name)}`);
|
|
58
|
+
console.error(error.message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (globalSlash === 'true' && !serverIdSlash) {
|
|
63
|
+
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
64
|
+
await rest.put(v10_1.Routes.applicationCommands((client.user?.id || '')), { body: slashCommandArray, headers: { Authorization: `Bot ${botToken}` } });
|
|
65
|
+
}
|
|
66
|
+
else if (globalSlash === 'false' && serverIdSlash) {
|
|
67
|
+
const guild = client.guilds.cache.get(serverIdSlash);
|
|
68
|
+
if (guild) {
|
|
69
|
+
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
70
|
+
await rest.put(v10_1.Routes.applicationGuildCommands((client.user?.id || ''), guild.id), { body: slashCommandArray, headers: { Authorization: `Bot ${botToken}` } });
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.error(`⚠️ Guild with ID ${serverIdSlash} not found.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
78
|
+
await rest.put(v10_1.Routes.applicationCommands((client.user?.id || '')), { body: slashCommandArray, headers: { Authorization: `Bot ${botToken}` } });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error('⚠️ Error registering slash commands:', error.message);
|
|
83
|
+
}
|
|
84
|
+
client.slashCommands = slashCommands;
|
|
85
|
+
client.slashSize = slashCommands.size;
|
|
86
|
+
return slashCommands;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=slashLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slashLoader.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slashLoader.ts"],"names":[],"mappings":";;;;;AAKA,kCA6EC;AAlFD,2CAA+C;AAC/C,0CAAuC;AACvC,+CAA+C;AAC/C,0CAAsC;AACtC,gDAAwB;AACjB,KAAK,UAAU,WAAW,CAAC,MAA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aAAa,CAAC,CAAC;YAClE,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACnG,MAAM,IAAI,CAAC,GAAG,CAAC,YAAM,CAAC,mBAAmB,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QACpJ,CAAC;IACL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,MAAM,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;IACtC,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -11,7 +11,7 @@ class Starter {
|
|
|
11
11
|
let verseDb;
|
|
12
12
|
try {
|
|
13
13
|
if (options.bot?.Database?.mongo) {
|
|
14
|
-
await (0, utils_1.mongoConnect)(options.bot.Database.mongo.mongoURI, options.bot.Database.mongo.dbName || '
|
|
14
|
+
await (0, utils_1.mongoConnect)(options.bot.Database.mongo.mongoURI, options.bot.Database.mongo.dbName || 'djsbuilder');
|
|
15
15
|
mongoDb = await (0, utils_1.getDb)();
|
|
16
16
|
}
|
|
17
17
|
if (options.bot?.Database?.verse) {
|
|
@@ -20,6 +20,7 @@ export interface BotOptions {
|
|
|
20
20
|
serverInvite?: string;
|
|
21
21
|
ownerId?: string;
|
|
22
22
|
partners?: string[];
|
|
23
|
+
developers?: string[];
|
|
23
24
|
};
|
|
24
25
|
Status?: {
|
|
25
26
|
state: 'online' | 'dnd' | 'idle' | 'invisible' | 'Streaming' | any;
|
|
@@ -90,6 +91,7 @@ export interface Command {
|
|
|
90
91
|
aliases?: string[];
|
|
91
92
|
cooldown?: number;
|
|
92
93
|
usage?: string;
|
|
94
|
+
developer?: boolean;
|
|
93
95
|
prefix?: boolean;
|
|
94
96
|
category?: string;
|
|
95
97
|
owner?: boolean;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CA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AAE,KAAK,IAAI,CAAC;IACnC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAA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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) {
|