reciple 9.4.1 → 9.5.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/README.md +11 -13
- package/dist/bin.js +2 -132
- package/dist/bin.js.map +1 -1
- package/dist/classes/CLI.d.ts +54 -0
- package/dist/classes/CLI.js +188 -0
- package/dist/classes/CLI.js.map +1 -0
- package/dist/classes/Config.d.ts +28 -51
- package/dist/classes/Config.js +54 -56
- package/dist/classes/Config.js.map +1 -1
- package/dist/classes/EventHandlers.d.ts +9 -0
- package/dist/classes/EventHandlers.js +71 -0
- package/dist/classes/EventHandlers.js.map +1 -0
- package/dist/classes/ModuleLoader.d.ts +25 -0
- package/dist/classes/ModuleLoader.js +95 -0
- package/dist/classes/ModuleLoader.js.map +1 -0
- package/dist/commands/dev.d.ts +12 -0
- package/dist/commands/dev.js +140 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +10 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/shard.d.ts +9 -0
- package/dist/commands/shard.js +101 -0
- package/dist/commands/shard.js.map +1 -0
- package/dist/commands/start.d.ts +9 -0
- package/dist/commands/start.js +94 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/exports.d.ts +5 -9
- package/dist/exports.js +5 -3
- package/dist/exports.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/constants.js +29 -0
- package/dist/types/constants.js.map +1 -0
- package/dist/types/structures.d.ts +36 -0
- package/dist/types/structures.js +2 -0
- package/dist/types/structures.js.map +1 -0
- package/package.json +8 -5
- package/static/config.d.mts +3 -1
- package/static/config.mjs +18 -0
- package/dist/utils/cli.d.ts +0 -60
- package/dist/utils/cli.js +0 -80
- package/dist/utils/cli.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -31
- package/dist/utils/logger.js +0 -87
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/modules.d.ts +0 -10
- package/dist/utils/modules.js +0 -44
- package/dist/utils/modules.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CLI } from '../classes/CLI.js';
|
|
2
|
+
import { Config } from '../classes/Config.js';
|
|
3
|
+
import { FileWriteStreamMode, Logger } from 'prtyprnt';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { ShardingManager } from 'discord.js';
|
|
6
|
+
import { resolveEnvProtocol } from '@reciple/utils';
|
|
7
|
+
import { EventHandlers } from '../index.js';
|
|
8
|
+
import { createReadStream } from 'fs';
|
|
9
|
+
import { kleur } from 'fallout-utility';
|
|
10
|
+
export default (command, cli) => command
|
|
11
|
+
.command('shard')
|
|
12
|
+
.description('Starts in sharding mode')
|
|
13
|
+
.option('-t, --token <DiscordToken>', 'Set your Discord Bot token')
|
|
14
|
+
.option('-c, --config <file>', 'Set the config file path', 'reciple.mjs')
|
|
15
|
+
.action(async () => {
|
|
16
|
+
let logger = cli.logger ?? null;
|
|
17
|
+
const startFlags = CLI.stringifyFlags(cli.getFlags('shard'), cli.getCommand('shard'));
|
|
18
|
+
const recipleFlags = CLI.stringifyFlags(cli.getFlags(), cli.getCommand(), ['cwd']);
|
|
19
|
+
const processFlags = [...startFlags, ...recipleFlags];
|
|
20
|
+
const processErrorLogger = (err) => {
|
|
21
|
+
logger?.error(err);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
};
|
|
24
|
+
process.once('uncaughtException', processErrorLogger);
|
|
25
|
+
process.once('unhandledRejection', processErrorLogger);
|
|
26
|
+
const flags = cli.getFlags('start', true);
|
|
27
|
+
const { config, sharding: shardingConfig } = await Config.readConfigFile({ path: flags.config, createIfNotExists: false }).then(data => data ?? ({ config: null, sharding: null }));
|
|
28
|
+
if (!config && !shardingConfig) {
|
|
29
|
+
logger?.error(`No config file found! Run ${kleur.green(`reciple init`)} to create one`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
let logFile = null;
|
|
33
|
+
let logsFolder = null;
|
|
34
|
+
process.env.SHARDS_DEPLOY_COMMANDS = '1';
|
|
35
|
+
if (!(config.logger instanceof Logger) && config.logger?.logToFile.enabled) {
|
|
36
|
+
logsFolder = path.resolve(path.join(config.logger?.logToFile?.logsFolder, 'sharder', process.pid.toString()));
|
|
37
|
+
logFile = path.join(logsFolder, config.logger?.logToFile?.file);
|
|
38
|
+
process.env.SHARDS_LOGS_FOLDER = logsFolder;
|
|
39
|
+
logger?.log(`Logs folder is at '${kleur.cyan(logsFolder)}'`);
|
|
40
|
+
}
|
|
41
|
+
logger = config.logger instanceof Logger
|
|
42
|
+
? config.logger
|
|
43
|
+
: config.logger?.enabled
|
|
44
|
+
? cli.logger?.clone({
|
|
45
|
+
label: 'Main',
|
|
46
|
+
writeStream: logFile ? await Logger.createFileWriteStream({
|
|
47
|
+
mode: FileWriteStreamMode.Rename,
|
|
48
|
+
path: logFile
|
|
49
|
+
}) : undefined
|
|
50
|
+
}) || null
|
|
51
|
+
: null;
|
|
52
|
+
config.token = flags.token ? resolveEnvProtocol(flags.token) ?? '' : config.token;
|
|
53
|
+
const manager = new ShardingManager(cli.binPath, {
|
|
54
|
+
...shardingConfig,
|
|
55
|
+
token: config.token,
|
|
56
|
+
shardArgs: processFlags,
|
|
57
|
+
});
|
|
58
|
+
EventHandlers.addExitListener(() => stopShardsProcess(manager));
|
|
59
|
+
manager.on('shardCreate', shard => {
|
|
60
|
+
let logs;
|
|
61
|
+
let readStream;
|
|
62
|
+
logger?.log(`Creating shard ${shard.id}...`);
|
|
63
|
+
shard.on('ready', () => {
|
|
64
|
+
logger?.log(`Shard ${shard.id} is ready!`);
|
|
65
|
+
if (!logs)
|
|
66
|
+
return;
|
|
67
|
+
logger?.log(`Logs for shards ${shard.id} is located at '${kleur.yellow(logs)}'`);
|
|
68
|
+
readStream = createReadStream(logs, 'utf-8');
|
|
69
|
+
if (logger?.writeStream)
|
|
70
|
+
readStream.pipe(logger.writeStream);
|
|
71
|
+
});
|
|
72
|
+
shard.on('reconnecting', () => logger?.log(`Shard ${shard.id} is reconnecting!`));
|
|
73
|
+
shard.on('disconnect', () => logger?.log(`Shard ${shard.id} disconnected!`));
|
|
74
|
+
shard.on('death', () => logger?.log(`Shard ${shard.id} died!`));
|
|
75
|
+
shard.on('error', err => logger?.log(`Shard ${shard.id} encountered an error!\n`, err));
|
|
76
|
+
shard.on('message', data => {
|
|
77
|
+
if (!('type' in data) || data.type !== 'ProcessInfo')
|
|
78
|
+
return;
|
|
79
|
+
logs = data.log;
|
|
80
|
+
if (process.env.SHARDS_DEPLOY_COMMANDS) {
|
|
81
|
+
delete process.env.SHARDS_DEPLOY_COMMANDS;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
logger?.log(`Starting ${manager.totalShards} shards...`);
|
|
86
|
+
await manager.spawn();
|
|
87
|
+
});
|
|
88
|
+
export function stopShardsProcess(shards) {
|
|
89
|
+
shards.shards.map(c => {
|
|
90
|
+
logger.log(`Killed ${c.id}`);
|
|
91
|
+
if (c.process) {
|
|
92
|
+
c.process?.kill('SIGINT');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
c.kill();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
logger.log(`Exitting process!`);
|
|
99
|
+
setTimeout(() => process.exit(0), 500);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=shard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shard.js","sourceRoot":"","sources":["../../src/commands/shard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAA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CAAC,CAAC;IAEH,MAAM,EAAE,GAAG,CAAC,YAAY,OAAO,CAAC,WAAW,YAAY,CAAC,CAAC;IACzD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEP,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACrD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAClB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAE7B,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACJ,CAAC,CAAC,IAAI,EAAE,CAAC;QACb,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { CLI } from '../classes/CLI.js';
|
|
3
|
+
export interface CLIStartFlags {
|
|
4
|
+
token?: string;
|
|
5
|
+
config: string;
|
|
6
|
+
production?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: (command: Command, cli: CLI) => Command;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CLI } from '../classes/CLI.js';
|
|
2
|
+
import { Config } from '../classes/Config.js';
|
|
3
|
+
import { Logger } from 'prtyprnt';
|
|
4
|
+
import { resolveEnvProtocol } from '@reciple/utils';
|
|
5
|
+
import semver from 'semver';
|
|
6
|
+
import { cliBuildVersion, cliVersion } from '../types/constants.js';
|
|
7
|
+
import { RecipleClient } from '../index.js';
|
|
8
|
+
import { buildVersion } from '@reciple/core';
|
|
9
|
+
import { EventHandlers } from '../classes/EventHandlers.js';
|
|
10
|
+
import { ModuleLoader } from '../classes/ModuleLoader.js';
|
|
11
|
+
import { kleur } from 'fallout-utility';
|
|
12
|
+
export default (command, cli) => command
|
|
13
|
+
.command('start', { isDefault: true })
|
|
14
|
+
.description('Starts the bot')
|
|
15
|
+
.option('-t, --token <DiscordToken>', 'Set your Discord Bot token')
|
|
16
|
+
.option('-c, --config <file>', 'Set the config file path', 'reciple.mjs')
|
|
17
|
+
.allowUnknownOption(true)
|
|
18
|
+
.action(async () => {
|
|
19
|
+
let logger = cli.logger ?? null;
|
|
20
|
+
const processErrorLogger = (err) => {
|
|
21
|
+
logger?.error(err);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
};
|
|
24
|
+
process.once('uncaughtException', processErrorLogger);
|
|
25
|
+
process.once('unhandledRejection', processErrorLogger);
|
|
26
|
+
process.on('warning', warn => logger?.warn(warn));
|
|
27
|
+
const flags = cli.getFlags('start', true);
|
|
28
|
+
const config = await Config.readConfigFile({ path: flags.config, createIfNotExists: false }).then(config => config?.config);
|
|
29
|
+
if (!config) {
|
|
30
|
+
logger?.error(`No config file found! Run ${kleur.green(`reciple init`)} to create one`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
logger = config.logger instanceof Logger
|
|
34
|
+
? config.logger
|
|
35
|
+
: config.logger?.enabled
|
|
36
|
+
? cli.logger?.clone(await Config.createLoggerOptions(config, { ...cli.logger.toJSON(), label: 'Reciple' }, cli)) || null
|
|
37
|
+
: null;
|
|
38
|
+
logger?.log(`Starting ${kleur.green('reciple@' + kleur.dim(cliBuildVersion) + ' @reciple/client@' + kleur.dim(buildVersion))} - ${kleur.dim(new Date().toISOString())}`);
|
|
39
|
+
if (!cli.shardDeployCommands) {
|
|
40
|
+
config.applicationCommandRegister = { ...config.applicationCommandRegister, enabled: false };
|
|
41
|
+
}
|
|
42
|
+
if (cli.shardMode)
|
|
43
|
+
await cli.sendProcessInfo();
|
|
44
|
+
config.token = flags.token ? resolveEnvProtocol(flags.token) ?? '' : config.token;
|
|
45
|
+
if (config.version && !semver.satisfies(cliVersion, config.version)) {
|
|
46
|
+
logger?.error(`Your config version doesn't support Reciple CLI v${cliVersion}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const client = new RecipleClient(config);
|
|
50
|
+
global.reciple = client;
|
|
51
|
+
if (logger)
|
|
52
|
+
global.logger = logger;
|
|
53
|
+
client.setLogger(logger);
|
|
54
|
+
EventHandlers.addClientEvents(client);
|
|
55
|
+
const modules = config.modules
|
|
56
|
+
? await client.modules.resolveModuleFiles({
|
|
57
|
+
files: await ModuleLoader.getModulePaths({
|
|
58
|
+
config: config.modules,
|
|
59
|
+
cwd: cli.cwd,
|
|
60
|
+
filter: ModuleLoader.defaultModulePathsFilter
|
|
61
|
+
}),
|
|
62
|
+
disableVersionCheck: config.modules?.disableModuleVersionCheck
|
|
63
|
+
})
|
|
64
|
+
: [];
|
|
65
|
+
const startData = await ModuleLoader.startModules(client, modules);
|
|
66
|
+
if (startData.failed.length)
|
|
67
|
+
logger?.error(`Failed to start ${startData.failed.length} module(s):\n ${startData.failed.map(m => m.displayName).join('\n ')}`);
|
|
68
|
+
client.on('ready', async () => {
|
|
69
|
+
if (!client.isReady())
|
|
70
|
+
return;
|
|
71
|
+
logger?.debug(`Client is ready!`);
|
|
72
|
+
process.removeListener('uncaughtException', processErrorLogger);
|
|
73
|
+
process.removeListener('unhandledRejection', processErrorLogger);
|
|
74
|
+
const loadData = await ModuleLoader.loadModules(client, modules);
|
|
75
|
+
if (loadData.failed.length)
|
|
76
|
+
logger?.error(`Failed to load ${loadData.failed.length} module(s):\n ${loadData.failed.map(m => m.displayName).join('\n ')}`);
|
|
77
|
+
process.stdin.resume();
|
|
78
|
+
EventHandlers.addExitListener((signal) => ModuleLoader.processExitHandleModuleUnload(client, signal));
|
|
79
|
+
EventHandlers.addCommandExecuteHandlers(client);
|
|
80
|
+
if (config.applicationCommandRegister?.enabled !== false)
|
|
81
|
+
await client.commands.registerApplicationCommands();
|
|
82
|
+
logger?.warn(`Logged in as ${kleur.bold().cyan(client.user.tag)} ${kleur.magenta('(' + client.user.id + ')')}`);
|
|
83
|
+
logger?.log(`Loaded ${client.commands.contextMenuCommands.size} context menu command(s)`);
|
|
84
|
+
logger?.log(`Loaded ${client.commands.messageCommands.size} message command(s)`);
|
|
85
|
+
logger?.log(`Loaded ${client.commands.slashCommands.size} slash command(s)`);
|
|
86
|
+
logger?.log(`Loaded ${client.commands.preconditions.size} global command precondition(s)`);
|
|
87
|
+
logger?.log(`Loaded ${client.commands.halts.size} global command halt(s)`);
|
|
88
|
+
if (!config.checkForUpdates)
|
|
89
|
+
cli.updateChecker?.stopCheckInterval();
|
|
90
|
+
});
|
|
91
|
+
logger?.debug(`Logging in...`);
|
|
92
|
+
await client.login().then(() => logger?.debug(`Login successful`));
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OA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AQ,CAAC,eAAe,CAAC,IAAI,qBAAqB,CAAC,CAAC;QACjF,MAAM,EAAE,GAAG,CAAC,UAAU,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,mBAAmB,CAAC,CAAC;QAC7E,MAAM,EAAE,GAAG,CAAC,UAAU,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,iCAAiC,CAAC,CAAC;QAC3F,MAAM,EAAE,GAAG,CAAC,UAAU,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,yBAAyB,CAAC,CAAC;QAE3E,IAAI,CAAC,MAAM,CAAC,eAAe;YAAE,GAAG,CAAC,aAAa,EAAE,iBAAiB,EAAE,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAE/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC"}
|
package/dist/exports.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
export * from './classes/CLI.js';
|
|
1
2
|
export * from './classes/Config.js';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export
|
|
6
|
-
type: 'ProcessInfo';
|
|
7
|
-
pid: number;
|
|
8
|
-
threadId: number;
|
|
9
|
-
log?: string;
|
|
10
|
-
}
|
|
3
|
+
export * from './classes/EventHandlers.js';
|
|
4
|
+
export * from './classes/ModuleLoader.js';
|
|
5
|
+
export * from './types/constants.js';
|
|
6
|
+
export * from './types/structures.js';
|
package/dist/exports.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './classes/CLI.js';
|
|
1
2
|
export * from './classes/Config.js';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
3
|
+
export * from './classes/EventHandlers.js';
|
|
4
|
+
export * from './classes/ModuleLoader.js';
|
|
5
|
+
export * from './types/constants.js';
|
|
6
|
+
export * from './types/structures.js';
|
|
5
7
|
//# sourceMappingURL=exports.js.map
|
package/dist/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Logger } from 'prtyprnt';
|
|
2
|
+
import type { CLI } from './classes/CLI.js';
|
|
3
|
+
import { RecipleClient as Client } from '@reciple/core';
|
|
4
|
+
import type { RecipleConfig } from './types/structures.js';
|
|
3
5
|
export * from '@reciple/core';
|
|
4
6
|
export * from './exports.js';
|
|
5
7
|
export { config as loadEnv } from 'dotenv';
|
|
@@ -7,7 +9,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
7
9
|
readonly config: RecipleConfig;
|
|
8
10
|
}
|
|
9
11
|
declare global {
|
|
12
|
+
var cli: CLI;
|
|
13
|
+
var logger: Logger;
|
|
10
14
|
var reciple: RecipleClient;
|
|
11
|
-
var logger: Logger | undefined;
|
|
12
|
-
var cli: typeof import('./utils/cli.js')['cli'];
|
|
13
15
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { cli, logger } from './types/constants.js';
|
|
1
2
|
import { RecipleClient as Client } from '@reciple/core';
|
|
2
3
|
export * from '@reciple/core';
|
|
3
4
|
export * from './exports.js';
|
|
5
|
+
global.cli = cli;
|
|
6
|
+
global.logger = logger;
|
|
4
7
|
export { config as loadEnv } from 'dotenv';
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;AAGxD,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;AACjB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;AAEvB,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { CLI } from '../classes/CLI.js';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { Logger } from '@reciple/core';
|
|
6
|
+
import { isDebugging } from 'fallout-utility';
|
|
7
|
+
import { coerce } from 'semver';
|
|
8
|
+
import { PackageUpdateChecker } from '@reciple/utils';
|
|
9
|
+
const packageJSON = JSON.parse(await readFile(path.join(CLI.root, './package.json'), 'utf-8'));
|
|
10
|
+
export const cliBuildVersion = packageJSON.version;
|
|
11
|
+
export const cliVersion = String(coerce(packageJSON.version));
|
|
12
|
+
export const logger = new Logger({
|
|
13
|
+
debugmode: {
|
|
14
|
+
enabled: isDebugging()
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export const cli = new CLI({
|
|
18
|
+
packageJSON,
|
|
19
|
+
binPath: path.join(CLI.root, './dist/bin.js'),
|
|
20
|
+
commander: new Command(),
|
|
21
|
+
processCwd: process.cwd(),
|
|
22
|
+
logger: logger.clone({
|
|
23
|
+
label: 'CLI'
|
|
24
|
+
}),
|
|
25
|
+
updateChecker: new PackageUpdateChecker({
|
|
26
|
+
packages: []
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/types/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;IAC7B,SAAS,EAAE;QACP,OAAO,EAAE,WAAW,EAAE;KACzB;CACJ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IACvB,WAAW;IACX,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC;IAC7C,SAAS,EAAE,IAAI,OAAO,EAAE;IACxB,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE;IACzB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;QACjB,KAAK,EAAE,KAAK;KACf,CAAC;IACF,aAAa,EAAE,IAAI,oBAAoB,CAAC;QACpC,QAAQ,EAAE,EAAE;KACf,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Logger, RecipleClientConfig } from '@reciple/core';
|
|
2
|
+
import type { Awaitable } from 'discord.js';
|
|
3
|
+
export interface CLIDefaultFlags {
|
|
4
|
+
cwd: string;
|
|
5
|
+
env: string[];
|
|
6
|
+
debug: boolean;
|
|
7
|
+
production: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface RecipleConfig extends RecipleClientConfig {
|
|
10
|
+
logger?: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
debugmode?: boolean | null;
|
|
13
|
+
coloredMessages: boolean;
|
|
14
|
+
disableLogPrefix: boolean;
|
|
15
|
+
logToFile: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
logsFolder: string;
|
|
18
|
+
file: string;
|
|
19
|
+
};
|
|
20
|
+
} | Logger;
|
|
21
|
+
modules?: {
|
|
22
|
+
dirs: string[];
|
|
23
|
+
exclude?: string[];
|
|
24
|
+
filter?: (file: string) => Awaitable<boolean>;
|
|
25
|
+
sort?: (a: string, b: string) => number;
|
|
26
|
+
disableModuleVersionCheck?: boolean;
|
|
27
|
+
};
|
|
28
|
+
checkForUpdates?: boolean;
|
|
29
|
+
version?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ProcessInformation {
|
|
32
|
+
type: 'ProcessInfo';
|
|
33
|
+
pid: number;
|
|
34
|
+
threadId: number;
|
|
35
|
+
log?: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structures.js","sourceRoot":"","sources":["../../src/types/structures.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Reciple is a Discord.js bot framework",
|
|
4
4
|
"homepage": "https://reciple.js.org/docs/reciple",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
|
-
"version": "9.
|
|
6
|
+
"version": "9.5.0",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"bin": "./dist/bin.js",
|
|
@@ -42,17 +42,20 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@reciple/utils": "^9.3.
|
|
45
|
+
"@reciple/utils": "^9.3.2",
|
|
46
|
+
"ansi-regex": "^6.0.1",
|
|
47
|
+
"chokidar": "^3.6.0",
|
|
46
48
|
"commander": "^12.1.0",
|
|
47
49
|
"dotenv": "^16.4.5",
|
|
48
50
|
"fallout-utility": "^2.9.1",
|
|
49
51
|
"globby": "^14.0.2",
|
|
50
52
|
"micromatch": "^4.0.7",
|
|
51
53
|
"prompts": "^2.4.2",
|
|
52
|
-
"
|
|
54
|
+
"prtyprnt": "^1.1.0",
|
|
55
|
+
"semver": "^7.6.3"
|
|
53
56
|
},
|
|
54
57
|
"devDependencies": {
|
|
55
|
-
"@reciple/core": "^9.
|
|
58
|
+
"@reciple/core": "^9.5.0",
|
|
56
59
|
"@types/micromatch": "^4.0.9",
|
|
57
60
|
"@types/semver": "^7.5.8",
|
|
58
61
|
"discord.js": "^14.15.3"
|
|
@@ -61,5 +64,5 @@
|
|
|
61
64
|
"@reciple/core": "^9 || ^9.0.0-dev",
|
|
62
65
|
"discord.js": "^14.15.0"
|
|
63
66
|
},
|
|
64
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "99e0be733c8e2ee4ec2e48e4cbcac4138ce8e291"
|
|
65
68
|
}
|
package/static/config.d.mts
CHANGED
package/static/config.mjs
CHANGED
|
@@ -77,3 +77,21 @@ export const config = {
|
|
|
77
77
|
checkForUpdates: true,
|
|
78
78
|
version: `^${cliVersion}`
|
|
79
79
|
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @satisfies {import('reciple').RecipleConfigJS['sharding']}
|
|
83
|
+
*/
|
|
84
|
+
export const sharding = {
|
|
85
|
+
mode: 'process'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @satisfies {import('reciple').RecipleConfigJS['devmode']}
|
|
90
|
+
*/
|
|
91
|
+
export const devmode = {
|
|
92
|
+
watch: ['modules/**/*', '*.json', 'reciple.*js', '.env*'],
|
|
93
|
+
ignore: ['node_modules/**/*', '.git/**/*', 'logs/**/*'],
|
|
94
|
+
exec: [],
|
|
95
|
+
noStart: false,
|
|
96
|
+
killSignal: 'SIGINT'
|
|
97
|
+
};
|
package/dist/utils/cli.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { PackageUpdateChecker } from '@reciple/utils';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
export declare let command: Command;
|
|
4
|
-
export interface CLIOptions {
|
|
5
|
-
version?: string;
|
|
6
|
-
token?: string;
|
|
7
|
-
config?: string;
|
|
8
|
-
debugmode?: boolean;
|
|
9
|
-
yes?: boolean;
|
|
10
|
-
env?: string;
|
|
11
|
-
shardmode?: boolean;
|
|
12
|
-
setup?: boolean;
|
|
13
|
-
[k: string]: any;
|
|
14
|
-
}
|
|
15
|
-
export declare const cli: {
|
|
16
|
-
/**
|
|
17
|
-
* This property returns the command-line arguments passed to the CLI. It is an array of strings, where each string represents an argument.
|
|
18
|
-
*/
|
|
19
|
-
readonly args: string[];
|
|
20
|
-
/**
|
|
21
|
-
* This property returns the command-line options passed to the CLI. It is an object with keys and values depending on the options specified in the command-line arguments.
|
|
22
|
-
*/
|
|
23
|
-
readonly options: CLIOptions;
|
|
24
|
-
/**
|
|
25
|
-
* This property returns the current working directory (CWD) of the CLI. It takes into account the command-line arguments passed to the CLI.
|
|
26
|
-
*/
|
|
27
|
-
readonly cwd: string;
|
|
28
|
-
/**
|
|
29
|
-
* This property returns a boolean value indicating whether shard mode is enabled or not.
|
|
30
|
-
* It is enabled if the shardmode option is specified in the command-line arguments, or if the `SHARDMODE` environment variable is set to `1`. Otherwise, it is disabled.
|
|
31
|
-
*/
|
|
32
|
-
readonly shardmode: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* This property returns the thread ID of the current thread, if it is not the main thread.
|
|
35
|
-
*/
|
|
36
|
-
threadId: number | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* This property is used to store a boolean value indicating whether the CWD has been updated or not.
|
|
39
|
-
*/
|
|
40
|
-
isCwdUpdated: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* This property returns the current working directory of the Node.js process.
|
|
43
|
-
*/
|
|
44
|
-
nodeCwd: string;
|
|
45
|
-
/**
|
|
46
|
-
* This property returns the path of the bin.mjs file, which is the main entry point of the CLI.
|
|
47
|
-
*/
|
|
48
|
-
binPath: string;
|
|
49
|
-
/**
|
|
50
|
-
* Reciple package root directory
|
|
51
|
-
*/
|
|
52
|
-
reciplePackagePath: string;
|
|
53
|
-
/**
|
|
54
|
-
* This property is used to store the path of the log file.
|
|
55
|
-
*/
|
|
56
|
-
logPath: string | undefined;
|
|
57
|
-
};
|
|
58
|
-
export declare const cliVersion: string;
|
|
59
|
-
export declare const cliBuildVersion: any;
|
|
60
|
-
export declare const updateChecker: PackageUpdateChecker;
|
package/dist/utils/cli.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { isMainThread, parentPort, threadId } from 'node:worker_threads';
|
|
2
|
-
import { PackageUpdateChecker } from '@reciple/utils';
|
|
3
|
-
import { buildVersion } from '@reciple/core';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { readFileSync } from 'node:fs';
|
|
6
|
-
import { Command } from 'commander';
|
|
7
|
-
import { coerce } from 'semver';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
const { version, description } = JSON.parse(readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), '../../package.json'), 'utf-8'));
|
|
10
|
-
const originalCwd = process.cwd();
|
|
11
|
-
export let command = new Command()
|
|
12
|
-
.name('reciple')
|
|
13
|
-
.description(description)
|
|
14
|
-
.version(`Reciple CLI: ${version}\nReciple Client: ${buildVersion}`, '-v, --version')
|
|
15
|
-
.argument('[cwd]', 'Change the current working directory')
|
|
16
|
-
.option('-t, --token <token>', 'Replace used bot token')
|
|
17
|
-
.option('-c, --config <dir>', 'Set path to a config file')
|
|
18
|
-
.option('-D, --debugmode', 'Enable debug mode')
|
|
19
|
-
.option('-y, --yes', 'Agree to all Reciple confirmation prompts')
|
|
20
|
-
.option('--env <file>', '.env file location')
|
|
21
|
-
.option('--shardmode', 'Modifies some functionalities to support sharding')
|
|
22
|
-
.option('--setup', 'Create required config without starting the bot')
|
|
23
|
-
.allowUnknownOption(true);
|
|
24
|
-
export const cli = {
|
|
25
|
-
/**
|
|
26
|
-
* This property returns the command-line arguments passed to the CLI. It is an array of strings, where each string represents an argument.
|
|
27
|
-
*/
|
|
28
|
-
get args() { return command.args; },
|
|
29
|
-
/**
|
|
30
|
-
* This property returns the command-line options passed to the CLI. It is an object with keys and values depending on the options specified in the command-line arguments.
|
|
31
|
-
*/
|
|
32
|
-
get options() { return command.opts(); },
|
|
33
|
-
/**
|
|
34
|
-
* This property returns the current working directory (CWD) of the CLI. It takes into account the command-line arguments passed to the CLI.
|
|
35
|
-
*/
|
|
36
|
-
get cwd() {
|
|
37
|
-
return this.args[0]
|
|
38
|
-
? path.isAbsolute(this.args[0]) ? this.args[0] : path.join(originalCwd, this.args[0])
|
|
39
|
-
: process.cwd();
|
|
40
|
-
},
|
|
41
|
-
/**
|
|
42
|
-
* This property returns a boolean value indicating whether shard mode is enabled or not.
|
|
43
|
-
* It is enabled if the shardmode option is specified in the command-line arguments, or if the `SHARDMODE` environment variable is set to `1`. Otherwise, it is disabled.
|
|
44
|
-
*/
|
|
45
|
-
get shardmode() { return !!(this.options.shardmode ?? process.env.SHARDMODE); },
|
|
46
|
-
/**
|
|
47
|
-
* This property returns the thread ID of the current thread, if it is not the main thread.
|
|
48
|
-
*/
|
|
49
|
-
threadId: !isMainThread && parentPort !== undefined ? threadId : undefined,
|
|
50
|
-
/**
|
|
51
|
-
* This property is used to store a boolean value indicating whether the CWD has been updated or not.
|
|
52
|
-
*/
|
|
53
|
-
isCwdUpdated: false,
|
|
54
|
-
/**
|
|
55
|
-
* This property returns the current working directory of the Node.js process.
|
|
56
|
-
*/
|
|
57
|
-
nodeCwd: process.cwd(),
|
|
58
|
-
/**
|
|
59
|
-
* This property returns the path of the bin.mjs file, which is the main entry point of the CLI.
|
|
60
|
-
*/
|
|
61
|
-
binPath: path.join(path.dirname(fileURLToPath(import.meta.url)), '../bin.mjs'),
|
|
62
|
-
/**
|
|
63
|
-
* Reciple package root directory
|
|
64
|
-
*/
|
|
65
|
-
reciplePackagePath: path.join(path.dirname(fileURLToPath(import.meta.url)), '../../'),
|
|
66
|
-
/**
|
|
67
|
-
* This property is used to store the path of the log file.
|
|
68
|
-
*/
|
|
69
|
-
logPath: undefined
|
|
70
|
-
};
|
|
71
|
-
global.cli = cli;
|
|
72
|
-
export const cliVersion = `${coerce(version)}`;
|
|
73
|
-
export const cliBuildVersion = version;
|
|
74
|
-
export const updateChecker = new PackageUpdateChecker({
|
|
75
|
-
packages: [
|
|
76
|
-
{ package: 'reciple', currentVersion: cliBuildVersion },
|
|
77
|
-
{ package: '@reciple/core', currentVersion: buildVersion }
|
|
78
|
-
]
|
|
79
|
-
});
|
|
80
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/utils/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAAA,OAA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AAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC;IACrF;;OAEG;IACH,OAAO,EAAE,SAA6B;CACzC,CAAC;AAEF,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;AAEjB,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC;IAClD,QAAQ,EAAE;QACN,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE;QACvD,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE;KAC7D;CACJ,CAAC,CAAC"}
|
package/dist/utils/logger.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Logger, LoggerLevel, type PartialDeep } from 'fallout-utility';
|
|
2
|
-
import type { RecipleConfig } from '../classes/Config.js';
|
|
3
|
-
import { type RecipleClient } from '../index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Formats a log message with optional prefix, colored messages, and thread information.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} message - The log message to format.
|
|
8
|
-
* @param {Logger} logger - The logger instance used to get the logger name.
|
|
9
|
-
* @param {PartialDeep<Exclude<RecipleConfig['logger'], Logger|undefined>> & { shards?: boolean; }} config - The logger configuration.
|
|
10
|
-
* @param {LoggerLevel} level - The log level.
|
|
11
|
-
* @return {string} The formatted log message.
|
|
12
|
-
*/
|
|
13
|
-
export declare function formatLogMessage(message: string, logger: Logger, config: PartialDeep<Exclude<RecipleConfig['logger'], Logger | undefined>> & {
|
|
14
|
-
shards?: boolean;
|
|
15
|
-
}, level: LoggerLevel): string;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a logger with the specified configuration.
|
|
18
|
-
*
|
|
19
|
-
* @param {Omit<PartialDeep<Exclude<RecipleConfig['logger'], Logger|undefined>>, 'enabled'> & { shards?: boolean; }} config - The configuration for the logger.
|
|
20
|
-
* @return {Promise<Logger>} The created logger instance.
|
|
21
|
-
*/
|
|
22
|
-
export declare function createLogger(config?: Omit<PartialDeep<Exclude<RecipleConfig['logger'], Logger | undefined>>, 'enabled'> & {
|
|
23
|
-
shards?: boolean;
|
|
24
|
-
}): Promise<Logger>;
|
|
25
|
-
/**
|
|
26
|
-
* Adds event listeners to the client for various module events and reciple events.
|
|
27
|
-
*
|
|
28
|
-
* @param {RecipleClient} client - The client to add the event listeners to.
|
|
29
|
-
* @return {void} This function does not return anything.
|
|
30
|
-
*/
|
|
31
|
-
export declare function addEventListenersToClient(client: RecipleClient): void;
|