reciple 6.0.0-dev.25 → 6.0.0-dev.27
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/dist/lib/bin.mjs +3 -2
- package/dist/lib/reciple/classes/RecipleClient.js +17 -6
- package/dist/lib/reciple/classes/managers/CommandManager.js +2 -1
- package/dist/lib/reciple/classes/managers/ModuleManager.js +4 -0
- package/dist/lib/reciple/util.js +2 -0
- package/dist/types/reciple/classes/RecipleClient.d.ts +10 -0
- package/package.json +2 -2
package/dist/lib/bin.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import match from 'micromatch';
|
|
|
10
10
|
import { inspect } from 'util';
|
|
11
11
|
import chalk from 'chalk';
|
|
12
12
|
import 'dotenv/config';
|
|
13
|
+
import { Events } from 'discord.js';
|
|
13
14
|
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', '.*'];
|
|
14
15
|
const configPath = path.join(cwd, 'reciple.yml');
|
|
15
16
|
if (!existsSync(cwd))
|
|
@@ -42,7 +43,7 @@ await client.modules.startModules({
|
|
|
42
43
|
}),
|
|
43
44
|
}),
|
|
44
45
|
});
|
|
45
|
-
client.on(
|
|
46
|
+
client.on(Events.ClientReady, async () => {
|
|
46
47
|
await client.modules.loadModules();
|
|
47
48
|
const unloadModulesAndStopProcess = async (signal) => {
|
|
48
49
|
await client.modules.unloadModules({ reason: 'ProcessExit' });
|
|
@@ -58,7 +59,7 @@ client.on('ready', async () => {
|
|
|
58
59
|
}
|
|
59
60
|
if (!client.isClientLogsSilent)
|
|
60
61
|
client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
|
|
61
|
-
client.on(
|
|
62
|
+
client.on(Events.CacheSweep, () => client.cooldowns.clean());
|
|
62
63
|
});
|
|
63
64
|
client.login(config.token).catch(err => {
|
|
64
65
|
if (!client.isClientLogsSilent)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RecipleClient = void 0;
|
|
3
|
+
exports.RecipleClient = exports.RecipleEvents = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
|
|
6
6
|
const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
|
|
@@ -17,6 +17,17 @@ const fallout_utility_1 = require("fallout-utility");
|
|
|
17
17
|
const util_1 = require("../util");
|
|
18
18
|
const version_js_1 = require("../version.js");
|
|
19
19
|
const flags_1 = require("../flags");
|
|
20
|
+
var RecipleEvents;
|
|
21
|
+
(function (RecipleEvents) {
|
|
22
|
+
RecipleEvents["RecipleCommandExecute"] = "recipleCommandExecute";
|
|
23
|
+
RecipleEvents["RecipleCommandHalt"] = "recipleCommandHalt";
|
|
24
|
+
RecipleEvents["RecipleRegisterApplicationCommands"] = "recipleRegisterApplicationCommands";
|
|
25
|
+
RecipleEvents["RecipleReplyError"] = "recipleReplyError";
|
|
26
|
+
RecipleEvents["CommandExecute"] = "recipleCommandExecute";
|
|
27
|
+
RecipleEvents["CommandHalt"] = "recipleCommandHalt";
|
|
28
|
+
RecipleEvents["RegisterApplicationCommands"] = "recipleRegisterApplicationCommands";
|
|
29
|
+
RecipleEvents["ReplyError"] = "recipleReplyError";
|
|
30
|
+
})(RecipleEvents = exports.RecipleEvents || (exports.RecipleEvents = {}));
|
|
20
31
|
class RecipleClient extends discord_js_1.Client {
|
|
21
32
|
/**
|
|
22
33
|
* @param options Client options
|
|
@@ -46,11 +57,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
46
57
|
* Listed to command executions
|
|
47
58
|
*/
|
|
48
59
|
addCommandListeners() {
|
|
49
|
-
this.on(
|
|
60
|
+
this.on(discord_js_1.Events.MessageCreate, message => {
|
|
50
61
|
if (this.config.commands.messageCommand.enabled)
|
|
51
62
|
this.messageCommandExecute(message);
|
|
52
63
|
});
|
|
53
|
-
this.on(
|
|
64
|
+
this.on(discord_js_1.Events.InteractionCreate, interaction => {
|
|
54
65
|
if (this.config.commands.slashCommand.enabled)
|
|
55
66
|
this.slashCommandExecute(interaction);
|
|
56
67
|
});
|
|
@@ -226,7 +237,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
226
237
|
* @param error Received Error
|
|
227
238
|
*/
|
|
228
239
|
_replyError(error) {
|
|
229
|
-
this.emit(
|
|
240
|
+
this.emit(RecipleEvents.ReplyError, error);
|
|
230
241
|
}
|
|
231
242
|
async _haltCommand(command, haltData) {
|
|
232
243
|
try {
|
|
@@ -235,7 +246,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
235
246
|
console.log(err);
|
|
236
247
|
})
|
|
237
248
|
: false) || false;
|
|
238
|
-
this.emit(
|
|
249
|
+
this.emit(RecipleEvents.CommandHalt, haltData);
|
|
239
250
|
return haltResolved;
|
|
240
251
|
}
|
|
241
252
|
catch (err) {
|
|
@@ -249,7 +260,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
249
260
|
async _executeCommand(command, executeData) {
|
|
250
261
|
try {
|
|
251
262
|
await Promise.resolve(command.type === builders_1.CommandType.SlashCommand ? command.execute(executeData) : command.execute(executeData))
|
|
252
|
-
.then(() => this.emit(
|
|
263
|
+
.then(() => this.emit(RecipleEvents.CommandExecute, executeData))
|
|
253
264
|
.catch(async (err) => !(await this._haltCommand(command, {
|
|
254
265
|
executeData: executeData,
|
|
255
266
|
reason: commands_1.CommandHaltReason.Error,
|
|
@@ -5,6 +5,7 @@ const builders_1 = require("../../types/builders");
|
|
|
5
5
|
const discord_js_1 = require("discord.js");
|
|
6
6
|
const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
|
|
7
7
|
const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
|
|
8
|
+
const RecipleClient_1 = require("../RecipleClient");
|
|
8
9
|
class CommandManager {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
this.slashCommands = new discord_js_1.Collection();
|
|
@@ -52,7 +53,7 @@ class CommandManager {
|
|
|
52
53
|
if (!this.client.isClientLogsSilent)
|
|
53
54
|
this.client.logger.log(`Regestering ${this.client.applicationCommands.size} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
|
|
54
55
|
await this.client.applicationCommands.set([...this.client.applicationCommands.commands], guilds);
|
|
55
|
-
this.client.emit(
|
|
56
|
+
this.client.emit(RecipleClient_1.RecipleEvents.RegisterApplicationCommands);
|
|
56
57
|
return this;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -7,6 +7,7 @@ const RecipleModule_1 = require("../RecipleModule");
|
|
|
7
7
|
const util_1 = require("../../util");
|
|
8
8
|
const util_2 = require("util");
|
|
9
9
|
const micromatch_1 = require("micromatch");
|
|
10
|
+
const version_1 = require("../../version");
|
|
10
11
|
class ModuleManager {
|
|
11
12
|
constructor(options) {
|
|
12
13
|
this.modules = new discord_js_1.Collection();
|
|
@@ -120,6 +121,9 @@ class ModuleManager {
|
|
|
120
121
|
}
|
|
121
122
|
if (!ModuleManager.validateScript(script))
|
|
122
123
|
throw new Error(`Invalid module script: ${file}`);
|
|
124
|
+
if (!this.client.config.disableVersionCheck && !(0, discord_js_1.normalizeArray)([script.versions])?.some(v => (0, version_1.isSupportedVersion)(v, this.client.version))) {
|
|
125
|
+
throw new Error(`Unsupported module: ${file}`);
|
|
126
|
+
}
|
|
123
127
|
modules.push(new RecipleModule_1.RecipleModule({
|
|
124
128
|
client: this.client,
|
|
125
129
|
script,
|
package/dist/lib/reciple/util.js
CHANGED
|
@@ -60,6 +60,8 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
|
|
|
60
60
|
[fallout_utility_1.LogLevels.ERROR]: (message) => (!colorizeMessage ? message : chalk_1.default.red(message)),
|
|
61
61
|
[fallout_utility_1.LogLevels.DEBUG]: (message) => (!colorizeMessage ? message : chalk_1.default.blue(message)),
|
|
62
62
|
},
|
|
63
|
+
ObjectInspectDepth: 3,
|
|
64
|
+
ObjectInspectColorized: colorizeMessage,
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
exports.createLogger = createLogger;
|
|
@@ -25,6 +25,16 @@ export interface RecipleClientEvents extends ClientEvents {
|
|
|
25
25
|
recipleRegisterApplicationCommands: [];
|
|
26
26
|
recipleReplyError: [error: unknown];
|
|
27
27
|
}
|
|
28
|
+
export declare enum RecipleEvents {
|
|
29
|
+
RecipleCommandExecute = "recipleCommandExecute",
|
|
30
|
+
RecipleCommandHalt = "recipleCommandHalt",
|
|
31
|
+
RecipleRegisterApplicationCommands = "recipleRegisterApplicationCommands",
|
|
32
|
+
RecipleReplyError = "recipleReplyError",
|
|
33
|
+
CommandExecute = "recipleCommandExecute",
|
|
34
|
+
CommandHalt = "recipleCommandHalt",
|
|
35
|
+
RegisterApplicationCommands = "recipleRegisterApplicationCommands",
|
|
36
|
+
ReplyError = "recipleReplyError"
|
|
37
|
+
}
|
|
28
38
|
/**
|
|
29
39
|
* Reciple client
|
|
30
40
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
3
|
"license": "GPL-3.0",
|
|
4
|
-
"version": "6.0.0-dev.
|
|
4
|
+
"version": "6.0.0-dev.27",
|
|
5
5
|
"bin": "./dist/lib/bin.mjs",
|
|
6
6
|
"author": "FalloutStudios",
|
|
7
7
|
"main": "./dist/lib/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"chalk": "4.1.2",
|
|
65
65
|
"commander": "^9.4.1",
|
|
66
66
|
"dotenv": "^16.0.3",
|
|
67
|
-
"fallout-utility": "^1.5.
|
|
67
|
+
"fallout-utility": "^1.5.15",
|
|
68
68
|
"micromatch": "^4.0.5",
|
|
69
69
|
"semver": "^7.3.7",
|
|
70
70
|
"yaml": "^2.1.1"
|