djs-builder 0.4.6 → 0.4.8
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/events loader.d.ts +3 -0
- package/dist/discord/events-handler/events loader.d.ts.map +1 -0
- package/dist/discord/events-handler/events loader.js +20 -0
- package/dist/discord/events-handler/events loader.js.map +1 -0
- package/dist/discord/events-handler/events.d.ts.map +1 -1
- package/dist/discord/events-handler/events.js +14 -11
- package/dist/discord/events-handler/events.js.map +1 -1
- package/dist/discord/events-handler/prefix-register.d.ts.map +1 -1
- package/dist/discord/events-handler/prefix-register.js +7 -4
- package/dist/discord/events-handler/prefix-register.js.map +1 -1
- package/dist/discord/events-handler/prefixLoader.d.ts +1 -14
- package/dist/discord/events-handler/prefixLoader.d.ts.map +1 -1
- package/dist/discord/events-handler/prefixLoader.js +12 -89
- package/dist/discord/events-handler/prefixLoader.js.map +1 -1
- package/dist/discord/events-handler/slash-register.d.ts.map +1 -1
- package/dist/discord/events-handler/slash-register.js +14 -7
- package/dist/discord/events-handler/slash-register.js.map +1 -1
- package/dist/discord/events-handler/slash-responder.d.ts.map +1 -1
- package/dist/discord/events-handler/slash-responder.js +7 -5
- package/dist/discord/events-handler/slash-responder.js.map +1 -1
- package/dist/discord/events-handler/slashLoader.d.ts +1 -2
- package/dist/discord/events-handler/slashLoader.d.ts.map +1 -1
- package/dist/discord/events-handler/slashLoader.js +11 -78
- package/dist/discord/events-handler/slashLoader.js.map +1 -1
- package/dist/discord/functions/logger.d.ts +5 -0
- package/dist/discord/functions/logger.d.ts.map +1 -0
- package/dist/discord/functions/logger.js +38 -0
- package/dist/discord/functions/logger.js.map +1 -0
- package/lib/discord/events-handler/events loader.ts +22 -0
- package/lib/discord/events-handler/events.ts +19 -16
- package/lib/discord/events-handler/prefix-register.ts +8 -4
- package/lib/discord/events-handler/prefixLoader.ts +16 -73
- package/lib/discord/events-handler/slash-register.ts +14 -8
- package/lib/discord/events-handler/slash-responder.ts +27 -25
- package/lib/discord/events-handler/slashLoader.ts +11 -75
- package/lib/discord/functions/logger.ts +39 -0
- package/package.json +1 -1
|
@@ -1,100 +1,23 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.commandNames = exports.aliases = exports.commands = void 0;
|
|
27
3
|
exports.prefixLoader = prefixLoader;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const path_1 = require("path");
|
|
4
|
+
const logger_1 = require("../functions/logger");
|
|
5
|
+
const prefix_register_1 = require("./prefix-register");
|
|
31
6
|
const login_1 = require("./login");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const commandDetails = [];
|
|
7
|
+
async function prefixLoader(client) {
|
|
8
|
+
prefix_register_1.commands.clear();
|
|
9
|
+
prefix_register_1.aliases.clear();
|
|
10
|
+
prefix_register_1.commandNames.clear();
|
|
37
11
|
const prefixPath = login_1.botData.get('prefixPath');
|
|
38
|
-
|
|
12
|
+
(0, logger_1.logInfo)(`Reloading prefix commands from ${prefixPath}`);
|
|
39
13
|
try {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for (const file of files) {
|
|
44
|
-
const filePath = (0, path_1.join)(resolvedPath, file.name);
|
|
45
|
-
if (file.isDirectory()) {
|
|
46
|
-
if ((0, path_1.basename)(filePath) !== (0, path_1.basename)(__filename)) { // Avoid processing the current file
|
|
47
|
-
const subCommandDetails = await prefixLoader(client, (0, path_1.join)(basePath, file.name));
|
|
48
|
-
commandDetails.push(...subCommandDetails);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else if (file.isFile()) {
|
|
52
|
-
try {
|
|
53
|
-
const commandModule = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s)));
|
|
54
|
-
const command = commandModule.default || commandModule;
|
|
55
|
-
if (command && (command.execute || command.run)) {
|
|
56
|
-
const defaultCommand = {
|
|
57
|
-
description: "No description provided.",
|
|
58
|
-
cooldown: undefined,
|
|
59
|
-
usage: "No usage information provided.",
|
|
60
|
-
aliases: [],
|
|
61
|
-
developer: false,
|
|
62
|
-
owner: false,
|
|
63
|
-
...command
|
|
64
|
-
};
|
|
65
|
-
exports.commands.set(defaultCommand.name, defaultCommand);
|
|
66
|
-
exports.commandNames.add(defaultCommand.name);
|
|
67
|
-
if (defaultCommand.aliases && Array.isArray(defaultCommand.aliases)) {
|
|
68
|
-
defaultCommand.aliases.forEach(alias => {
|
|
69
|
-
exports.aliases.set(alias, defaultCommand.name);
|
|
70
|
-
exports.commandNames.add(alias);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
commandDetails.push({
|
|
74
|
-
name: defaultCommand.name,
|
|
75
|
-
usage: defaultCommand.usage || 'No usage information provided.',
|
|
76
|
-
description: defaultCommand.description || 'No description provided.',
|
|
77
|
-
aliases: defaultCommand.aliases || [],
|
|
78
|
-
cooldown: defaultCommand.cooldown,
|
|
79
|
-
developer: defaultCommand.developer,
|
|
80
|
-
owner: defaultCommand.owner,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
console.error(`Error in file: ${filePath}`);
|
|
86
|
-
console.error(error.message);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
client.prefixCommands = commandDetails;
|
|
91
|
-
client.prefixSize = commandDetails.length;
|
|
92
|
-
return commandDetails;
|
|
14
|
+
const newCommandDetails = await (0, prefix_register_1.readCommands)(client, { path: prefixPath });
|
|
15
|
+
(0, logger_1.logSuccess)(`Successfully reloaded ${newCommandDetails.length} prefix commands.`);
|
|
16
|
+
return true;
|
|
93
17
|
}
|
|
94
18
|
catch (error) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return [];
|
|
19
|
+
(0, logger_1.logError)(`Error reloading prefix commands: ${error.message}`);
|
|
20
|
+
return false;
|
|
98
21
|
}
|
|
99
22
|
}
|
|
100
23
|
//# sourceMappingURL=prefixLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefixLoader.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/prefixLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prefixLoader.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/prefixLoader.ts"],"names":[],"mappings":";;AAGA,oCAkBC;AArBD,gDAAoE;AACpE,uDAAkF;AAClF,mCAAmC;AAC5B,KAAK,UAAU,YAAY,CAAC,MAAW;IAC1C,0BAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,yBAAO,CAAC,KAAK,EAAE,CAAC;IAChB,8BAAY,CAAC,KAAK,EAAE,CAAC;IAErB,MAAM,UAAU,GAAG,eAAO,CAAC,GAAG,CAAC,YAAY,CAAW,CAAC;IAEvD,IAAA,gBAAO,EAAC,kCAAkC,UAAU,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC;QACD,MAAM,iBAAiB,GAAG,MAAM,IAAA,8BAAY,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAC3E,IAAA,mBAAU,EAAC,yBAAyB,iBAAiB,CAAC,MAAM,mBAAmB,CAAC,CAAC;QACjF,OAAO,IAAI,CAAA;IACf,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAA,iBAAQ,EAAC,oCAAoC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,OAAO,KAAK,CAAA;IAEhB,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAGhD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CA2E7H"}
|
|
@@ -9,9 +9,10 @@ const rest_1 = require("@discordjs/rest");
|
|
|
9
9
|
const v10_1 = require("discord-api-types/v10");
|
|
10
10
|
const promises_1 = require("fs/promises");
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const logger_1 = require("../functions/logger");
|
|
12
13
|
async function registerSlashCommands(client, token, slash) {
|
|
13
14
|
if (!token) {
|
|
14
|
-
throw new Error("⚠️
|
|
15
|
+
throw new Error("⚠️ Please provide valid bot token to register slash commands.");
|
|
15
16
|
}
|
|
16
17
|
const slashCommands = new discord_js_1.Collection();
|
|
17
18
|
const rest = new rest_1.REST({ version: '10' }).setToken(token);
|
|
@@ -30,11 +31,12 @@ async function registerSlashCommands(client, token, slash) {
|
|
|
30
31
|
command.data.cooldown = command.cooldown || 0;
|
|
31
32
|
}
|
|
32
33
|
slashCommands.set(command.data.name, command);
|
|
34
|
+
(0, logger_1.logInfo)(`Loaded command: ${command.data.name}`);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
catch (error) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
(0, logger_1.logError)(`Error in file: ${path_1.default.join(folderPath, file)}`);
|
|
39
|
+
(0, logger_1.logError)(error.message);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -46,35 +48,40 @@ async function registerSlashCommands(client, token, slash) {
|
|
|
46
48
|
command.data.cooldown = command.cooldown || 0;
|
|
47
49
|
}
|
|
48
50
|
slashCommands.set(command.data.name, command);
|
|
51
|
+
(0, logger_1.logInfo)(`Loaded command: ${command.data.name}`);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
catch (error) {
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
(0, logger_1.logError)(`Error in file: ${path_1.default.join(resolvedPath, dirent.name)}`);
|
|
56
|
+
(0, logger_1.logError)(error.message);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
if (slash.global && !slash.serverId) {
|
|
58
61
|
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
59
62
|
await rest.put(v10_1.Routes.applicationCommands((client.user?.id || '')), { body: slashCommandArray, headers: { Authorization: `Bot ${token}` } });
|
|
63
|
+
(0, logger_1.logSuccess)('Successfully registered global slash commands.');
|
|
60
64
|
}
|
|
61
65
|
else if (!slash.global && slash.serverId) {
|
|
62
66
|
const guild = client.guilds.cache.get(slash.serverId);
|
|
63
67
|
if (guild) {
|
|
64
68
|
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
65
69
|
await rest.put(v10_1.Routes.applicationGuildCommands((client.user?.id || ''), guild.id), { body: slashCommandArray, headers: { Authorization: `Bot ${token}` } });
|
|
70
|
+
(0, logger_1.logSuccess)(`Successfully registered guild slash commands for server ID: ${slash.serverId}`);
|
|
66
71
|
}
|
|
67
72
|
else {
|
|
68
|
-
|
|
73
|
+
(0, logger_1.logError)(`Guild with ID ${slash.serverId} not found.`);
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
else {
|
|
72
77
|
const slashCommandArray = Array.from(slashCommands.values()).map(command => command.data.toJSON());
|
|
73
78
|
await rest.put(v10_1.Routes.applicationCommands((client.user?.id || '')), { body: slashCommandArray, headers: { Authorization: `Bot ${token}` } });
|
|
79
|
+
(0, logger_1.logSuccess)('Successfully registered global slash commands.');
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
catch (error) {
|
|
77
|
-
|
|
83
|
+
(0, logger_1.logError)('Error registering slash commands:');
|
|
84
|
+
(0, logger_1.logError)(error.message);
|
|
78
85
|
}
|
|
79
86
|
client.slashCommands = slashCommands;
|
|
80
87
|
client.slashSize = slashCommands.size;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slash-register.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-register.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"slash-register.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-register.ts"],"names":[],"mappings":";;;;;AAQA,sDA2EC;AAnFD,2CAA+C;AAC/C,0CAAuC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U,EAAC,+DAA+D,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAChG,CAAC;iBAAM,CAAC;gBACJ,IAAA,iBAAQ,EAAC,iBAAiB,KAAK,CAAC,QAAQ,aAAa,CAAC,CAAC;YAC3D,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,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;YAC7I,IAAA,mBAAU,EAAC,gDAAgD,CAAC,CAAC;QACjE,CAAC;IACL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAA,iBAAQ,EAAC,mCAAmC,CAAC,CAAC;QAC9C,IAAA,iBAAQ,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,MAAM,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;IACtC,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slash-responder.d.ts","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-responder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0E,MAAM,YAAY,CAAC;AAE5G,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"slash-responder.d.ts","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-responder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0E,MAAM,YAAY,CAAC;AAE5G,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAwHnG"}
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadSlash = loadSlash;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const slash_register_1 = require("./slash-register");
|
|
6
|
+
const logger_1 = require("../functions/logger");
|
|
6
7
|
async function loadSlash(client, token, options) {
|
|
7
8
|
const slashCommands = await (0, slash_register_1.registerSlashCommands)(client, token, options);
|
|
8
9
|
if (!slashCommands || slashCommands.size === 0) {
|
|
9
|
-
|
|
10
|
+
(0, logger_1.logWarning)('No registered slash commands. SlashHandler won\'t work.');
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const interactionCooldowns = new discord_js_1.Collection();
|
|
@@ -52,6 +53,7 @@ async function loadSlash(client, token, options) {
|
|
|
52
53
|
userCooldowns.set(command.data.name, Date.now() + command.cooldown * 1000);
|
|
53
54
|
interactionCooldowns.set(interaction.user.id, userCooldowns);
|
|
54
55
|
}
|
|
56
|
+
const startExecutionTime = Date.now();
|
|
55
57
|
try {
|
|
56
58
|
if (command.run) {
|
|
57
59
|
if (command.run.length === 2) {
|
|
@@ -70,9 +72,8 @@ async function loadSlash(client, token, options) {
|
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
else {
|
|
73
|
-
|
|
75
|
+
(0, logger_1.logWarning)(`Command "${command.data.name}" has neither run nor execute method.`);
|
|
74
76
|
}
|
|
75
|
-
const startExecutionTime = Date.now();
|
|
76
77
|
const channel = interaction.guild.channels.cache.get(options.logsId || '');
|
|
77
78
|
const userName = interaction.user.username;
|
|
78
79
|
const userId = interaction.user.id;
|
|
@@ -96,11 +97,12 @@ async function loadSlash(client, token, options) {
|
|
|
96
97
|
}
|
|
97
98
|
const executionTime = Date.now() - startExecutionTime;
|
|
98
99
|
if (executionTime > 3000) {
|
|
99
|
-
|
|
100
|
+
(0, logger_1.logInfo)(`Command "${command.data.name}" took ${executionTime}ms to execute.`);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
catch (error) {
|
|
103
|
-
|
|
104
|
+
(0, logger_1.logError)(`Error executing command "${command.data.name}":`);
|
|
105
|
+
(0, logger_1.logError)(error.message);
|
|
104
106
|
if (interaction.channel) {
|
|
105
107
|
await interaction.channel.send({ content: 'An error occurred while executing the command.' });
|
|
106
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slash-responder.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-responder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"slash-responder.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slash-responder.ts"],"names":[],"mappings":";;AAKA,8BAwHC;AA7HD,2CAA4G;AAC5G,qDAAyD;AAEzD,gDAAoE;AAE7D,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,KAAa,EAAE,OAAqB;IAChF,MAAM,aAAa,GAAG,MAAM,IAAA,sCAAqB,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAE1E,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC7C,IAAA,mBAAU,EAAC,yDAAyD,CAAC,CAAC;QACtE,OAAO;IACX,CAAC;IAED,MAAM,oBAAoB,GAAsD,IAAI,uBAAU,EAAE,CAAC;IAEjG,MAAM,CAAC,EAAE,CAAC,mBAAmB,EAAE,KAAK,EAAE,WAAwB,EAAE,EAAE;QAC9D,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,KAA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ACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,IAAA,iBAAQ,EAAC,4BAA4B,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;YAC5D,IAAA,iBAAQ,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACxB,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,gDAAgD,EAAE,CAAC,CAAC;YAClG,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function slashLoader(client: any): Promise<Collection<string, any>>;
|
|
1
|
+
export declare function slashLoader(client: any, token: string, global: boolean, serverId?: string): Promise<boolean>;
|
|
3
2
|
//# sourceMappingURL=slashLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashLoader.d.ts","sourceRoot":"","sources":["../../../lib/discord/events-handler/slashLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slashLoader.d.ts","sourceRoot":"","sources":["../../../lib/discord/events-handler/slashLoader.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,oBAc/F"}
|
|
@@ -1,88 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.slashLoader = slashLoader;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const v10_1 = require("discord-api-types/v10");
|
|
10
|
-
const promises_1 = require("fs/promises");
|
|
4
|
+
const logger_1 = require("../functions/logger");
|
|
5
|
+
const slash_register_1 = require("./slash-register");
|
|
11
6
|
const login_1 = require("./login");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const globalSlash = login_1.botData.get('globalSlash');
|
|
17
|
-
const botToken = login_1.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);
|
|
7
|
+
async function slashLoader(client, token, global, serverId) {
|
|
8
|
+
client.slashCommands.clear();
|
|
9
|
+
const slashPath = login_1.botData.get('slashPath');
|
|
10
|
+
(0, logger_1.logInfo)(`Reloading slash commands from ${slashPath}`);
|
|
23
11
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
}
|
|
12
|
+
const newSlashCommands = await (0, slash_register_1.registerSlashCommands)(client, token, { path: slashPath, global, serverId });
|
|
13
|
+
(0, logger_1.logSuccess)(`Successfully reloaded ${newSlashCommands.size} slash commands.`);
|
|
14
|
+
return true;
|
|
80
15
|
}
|
|
81
16
|
catch (error) {
|
|
82
|
-
|
|
17
|
+
(0, logger_1.logError)(`Error reloading slash commands: ${error.message}`);
|
|
18
|
+
return false;
|
|
83
19
|
}
|
|
84
|
-
client.slashCommands = slashCommands;
|
|
85
|
-
client.slashSize = slashCommands.size;
|
|
86
|
-
return slashCommands;
|
|
87
20
|
}
|
|
88
21
|
//# sourceMappingURL=slashLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashLoader.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slashLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slashLoader.js","sourceRoot":"","sources":["../../../lib/discord/events-handler/slashLoader.ts"],"names":[],"mappings":";;AAIA,kCAcC;AAlBD,gDAAoE;AACpE,qDAAyD;AACzD,mCAAkC;AAE3B,KAAK,UAAU,WAAW,CAAC,MAAW,EAAE,KAAa,EAAE,MAAe,EAAE,QAAiB;IAC5F,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,eAAO,CAAC,GAAG,CAAC,WAAW,CAAW,CAAC;IAErD,IAAA,gBAAO,EAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;IAEtD,IAAI,CAAC;QACD,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAqB,EAAC,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3G,IAAA,mBAAU,EAAC,yBAAyB,gBAAgB,CAAC,IAAI,kBAAkB,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAA;IACf,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAA,iBAAQ,EAAC,mCAAmC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function logSuccess(message: string): void;
|
|
2
|
+
export declare function logError(message: string): void;
|
|
3
|
+
export declare function logInfo(message: string): void;
|
|
4
|
+
export declare function logWarning(message: string): void;
|
|
5
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../lib/discord/functions/logger.ts"],"names":[],"mappings":"AAuBA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,QAEvC;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,QAEtC;AAGD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,QAEzC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logSuccess = logSuccess;
|
|
4
|
+
exports.logError = logError;
|
|
5
|
+
exports.logInfo = logInfo;
|
|
6
|
+
exports.logWarning = logWarning;
|
|
7
|
+
const successEmoji = '✅';
|
|
8
|
+
const errorEmoji = '❌';
|
|
9
|
+
const infoEmoji = 'ℹ️';
|
|
10
|
+
const warningEmoji = '⚠️';
|
|
11
|
+
const green = '\x1b[32m';
|
|
12
|
+
const red = '\x1b[31m';
|
|
13
|
+
const cyan = '\x1b[36m';
|
|
14
|
+
const reset = '\x1b[0m';
|
|
15
|
+
const yellow = '\x1b[33m';
|
|
16
|
+
function getTimestamp() {
|
|
17
|
+
const now = new Date();
|
|
18
|
+
const year = now.getFullYear();
|
|
19
|
+
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
20
|
+
const day = String(now.getDate()).padStart(2, '0');
|
|
21
|
+
const hours = String(now.getHours()).padStart(2, '0');
|
|
22
|
+
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
23
|
+
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
24
|
+
return `[${year}-${month}-${day} ${hours}:${minutes}:${seconds}]`;
|
|
25
|
+
}
|
|
26
|
+
function logSuccess(message) {
|
|
27
|
+
console.log(`${getTimestamp()} ${green}${successEmoji}${reset} ${green}${message}${reset}`);
|
|
28
|
+
}
|
|
29
|
+
function logError(message) {
|
|
30
|
+
console.error(`${getTimestamp()} ${red}${errorEmoji}${reset} ${red}${message}${reset}`);
|
|
31
|
+
}
|
|
32
|
+
function logInfo(message) {
|
|
33
|
+
console.log(`${getTimestamp()} ${cyan}${infoEmoji}${reset} ${cyan}${message}${reset}`);
|
|
34
|
+
}
|
|
35
|
+
function logWarning(message) {
|
|
36
|
+
console.warn(`${getTimestamp()} ${yellow}${warningEmoji}${reset} ${yellow}${message}${reset}`);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../lib/discord/functions/logger.ts"],"names":[],"mappings":";;AAuBA,gCAEC;AAED,4BAEC;AAED,0BAEC;AAGD,gCAEC;AAtCD,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,MAAM,GAAG,UAAU,CAAC;AAG1B,SAAS,YAAY;IACjB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,M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,GAAG,KAAK,EAAE,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { logSuccess, logError, logInfo } from '../functions/logger';
|
|
2
|
+
import { EventsOptions } from '../types/starter';
|
|
3
|
+
import { loadEvents } from './events';
|
|
4
|
+
import { botData } from './login';
|
|
5
|
+
export async function eventsLoader(client: any, eventsOptions: EventsOptions) {
|
|
6
|
+
|
|
7
|
+
client.eventSize = 0;
|
|
8
|
+
client.removeAllListeners();
|
|
9
|
+
|
|
10
|
+
logInfo(`Reloading events from ${eventsOptions.path}`);
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
|
|
14
|
+
await loadEvents(client, eventsOptions);
|
|
15
|
+
|
|
16
|
+
logSuccess(`Successfully reloaded ${client.eventSize} events.`);
|
|
17
|
+
return true
|
|
18
|
+
} catch (error: any) {
|
|
19
|
+
logError(`Error reloading events: ${error.message}`);
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logSuccess, logError, logInfo } from '../functions/logger';
|
|
1
2
|
import { readdir, stat } from 'fs/promises';
|
|
2
3
|
import { resolve, join, extname } from 'path';
|
|
3
4
|
import { EventsOptions, Event } from '../types/utils';
|
|
@@ -45,9 +46,9 @@ async function processEventFile(client: any, eventsOptions: EventsOptions, fileP
|
|
|
45
46
|
eventHandler = await withRetry(eventHandler, event.retryAttempts);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
} catch (error: any) {
|
|
50
|
+
logError(`Error in event file: ${filePath}`);
|
|
51
|
+
logError(error.message);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -78,12 +79,13 @@ async function withRetry(handler: (...args: any[]) => Promise<void>, retryAttemp
|
|
|
78
79
|
try {
|
|
79
80
|
await handler(...args);
|
|
80
81
|
return;
|
|
81
|
-
} catch (error) {
|
|
82
|
-
|
|
82
|
+
} catch (error: any) {
|
|
83
|
+
logError('Error executing event:');
|
|
84
|
+
logError(error.message);
|
|
83
85
|
attempts++;
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
|
|
88
|
+
logError('Reached maximum retry attempts.');
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
|
|
@@ -99,9 +101,9 @@ async function processDirectory(client: any, eventsOptions: EventsOptions, direc
|
|
|
99
101
|
await processEventFile(client, eventsOptions, filePath);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
|
-
} catch (error) {
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
} catch (error: any) {
|
|
105
|
+
logError(`Error while processing directory: ${directoryPath}`);
|
|
106
|
+
logError(error.message);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -116,14 +118,15 @@ export async function loadEvents(client: any, eventsOptions: EventsOptions) {
|
|
|
116
118
|
} else if (stats.isFile()) {
|
|
117
119
|
await processEventFile(client, eventsOptions, eventsOptions.path);
|
|
118
120
|
} else {
|
|
119
|
-
|
|
121
|
+
logError(`Invalid file or directory: ${resolvedPath}`);
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
const eventCount = await countEventFiles(eventsOptions.path, eventsOptions);
|
|
123
125
|
client.eventSize = eventCount;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
logSuccess(`Loaded ${eventCount} events successfully.`);
|
|
127
|
+
} catch (error: any) {
|
|
128
|
+
logError(`Error while loading events from path: ${eventsOptions.path}`);
|
|
129
|
+
logError(error.message);
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
|
|
@@ -149,9 +152,9 @@ async function countEventFiles(filePath: string, eventsOptions: EventsOptions):
|
|
|
149
152
|
} else if (stats.isFile() && validExtensions.includes(extname(resolvedPath))) {
|
|
150
153
|
count++;
|
|
151
154
|
}
|
|
152
|
-
} catch (error) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
} catch (error: any) {
|
|
156
|
+
logError(`Error counting event files in directory: ${filePath}`);
|
|
157
|
+
logError(error.message);
|
|
155
158
|
}
|
|
156
159
|
return count;
|
|
157
160
|
}
|