reciple 6.0.4 → 7.0.0-dev.5
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/LICENSE +674 -674
- package/bin/bin.d.mts +2 -0
- package/bin/bin.mjs +73 -0
- package/bin/bin.mjs.map +1 -0
- package/bin/classes/Config.d.ts +32 -0
- package/bin/classes/Config.js +72 -0
- package/bin/classes/Config.js.map +1 -0
- package/bin/esm.d.mts +1 -0
- package/{dist/lib → bin}/esm.mjs +0 -0
- package/bin/esm.mjs.map +1 -0
- package/bin/index.d.ts +5 -0
- package/bin/index.js +22 -0
- package/bin/index.js.map +1 -0
- package/bin/utils/cli.d.ts +4 -0
- package/bin/utils/cli.js +20 -0
- package/bin/utils/cli.js.map +1 -0
- package/bin/utils/logger.d.ts +6 -0
- package/bin/utils/logger.js +61 -0
- package/bin/utils/logger.js.map +1 -0
- package/bin/utils/modules.d.ts +3 -0
- package/bin/utils/modules.js +35 -0
- package/bin/utils/modules.js.map +1 -0
- package/package.json +25 -67
- package/static/config.yml +97 -0
- package/README.md +0 -182
- package/dist/lib/bin.mjs +0 -77
- package/dist/lib/bin.mjs.map +0 -1
- package/dist/lib/esm.mjs.map +0 -1
- package/dist/lib/index.js +0 -34
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/reciple/classes/RecipleClient.js +0 -293
- package/dist/lib/reciple/classes/RecipleClient.js.map +0 -1
- package/dist/lib/reciple/classes/RecipleConfig.js +0 -107
- package/dist/lib/reciple/classes/RecipleConfig.js.map +0 -1
- package/dist/lib/reciple/classes/RecipleModule.js +0 -137
- package/dist/lib/reciple/classes/RecipleModule.js.map +0 -1
- package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +0 -316
- package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js.map +0 -1
- package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js +0 -127
- package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js.map +0 -1
- package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js +0 -253
- package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js.map +0 -1
- package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js +0 -179
- package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js.map +0 -1
- package/dist/lib/reciple/classes/managers/CommandCooldownManager.js +0 -100
- package/dist/lib/reciple/classes/managers/CommandCooldownManager.js.map +0 -1
- package/dist/lib/reciple/classes/managers/CommandManager.js +0 -65
- package/dist/lib/reciple/classes/managers/CommandManager.js.map +0 -1
- package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +0 -26
- package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js.map +0 -1
- package/dist/lib/reciple/classes/managers/ModuleManager.js +0 -181
- package/dist/lib/reciple/classes/managers/ModuleManager.js.map +0 -1
- package/dist/lib/reciple/flags.js +0 -32
- package/dist/lib/reciple/flags.js.map +0 -1
- package/dist/lib/reciple/permissions.js +0 -31
- package/dist/lib/reciple/permissions.js.map +0 -1
- package/dist/lib/reciple/types/builders.js +0 -12
- package/dist/lib/reciple/types/builders.js.map +0 -1
- package/dist/lib/reciple/types/commands.js +0 -16
- package/dist/lib/reciple/types/commands.js.map +0 -1
- package/dist/lib/reciple/types/paramOptions.js +0 -3
- package/dist/lib/reciple/types/paramOptions.js.map +0 -1
- package/dist/lib/reciple/util.js +0 -72
- package/dist/lib/reciple/util.js.map +0 -1
- package/dist/lib/reciple/version.js +0 -48
- package/dist/lib/reciple/version.js.map +0 -1
- package/dist/types/bin.d.mts +0 -3
- package/dist/types/bin.d.mts.map +0 -1
- package/dist/types/esm.d.mts +0 -2
- package/dist/types/esm.d.mts.map +0 -1
- package/dist/types/index.d.ts +0 -18
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/reciple/classes/RecipleClient.d.ts +0 -116
- package/dist/types/reciple/classes/RecipleClient.d.ts.map +0 -1
- package/dist/types/reciple/classes/RecipleConfig.d.ts +0 -102
- package/dist/types/reciple/classes/RecipleConfig.d.ts.map +0 -1
- package/dist/types/reciple/classes/RecipleModule.d.ts +0 -88
- package/dist/types/reciple/classes/RecipleModule.d.ts.map +0 -1
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +0 -198
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts.map +0 -1
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +0 -54
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts.map +0 -1
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +0 -107
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts.map +0 -1
- package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +0 -54
- package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts.map +0 -1
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +0 -71
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts.map +0 -1
- package/dist/types/reciple/classes/managers/CommandManager.d.ts +0 -35
- package/dist/types/reciple/classes/managers/CommandManager.d.ts.map +0 -1
- package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +0 -23
- package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts.map +0 -1
- package/dist/types/reciple/classes/managers/ModuleManager.d.ts +0 -50
- package/dist/types/reciple/classes/managers/ModuleManager.d.ts.map +0 -1
- package/dist/types/reciple/flags.d.ts +0 -18
- package/dist/types/reciple/flags.d.ts.map +0 -1
- package/dist/types/reciple/permissions.d.ts +0 -16
- package/dist/types/reciple/permissions.d.ts.map +0 -1
- package/dist/types/reciple/types/builders.d.ts +0 -206
- package/dist/types/reciple/types/builders.d.ts.map +0 -1
- package/dist/types/reciple/types/commands.d.ts +0 -86
- package/dist/types/reciple/types/commands.d.ts.map +0 -1
- package/dist/types/reciple/types/paramOptions.d.ts +0 -102
- package/dist/types/reciple/types/paramOptions.d.ts.map +0 -1
- package/dist/types/reciple/util.d.ts +0 -27
- package/dist/types/reciple/util.d.ts.map +0 -1
- package/dist/types/reciple/version.d.ts +0 -26
- package/dist/types/reciple/version.d.ts.map +0 -1
- package/resource/reciple.yml +0 -122
package/bin/bin.d.mts
ADDED
package/bin/bin.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync } from 'fs';
|
|
3
|
+
import { flags, cwd } from './utils/cli.js';
|
|
4
|
+
import { path } from 'fallout-utility';
|
|
5
|
+
import micromatch from 'micromatch';
|
|
6
|
+
import promptConfirm from '@inquirer/confirm';
|
|
7
|
+
import { Config } from './classes/Config.js';
|
|
8
|
+
import { ContextMenuCommandBuilder, MessageCommandBuilder, RecipleClient, SlashCommandBuilder, realVersion } from '@reciple/client';
|
|
9
|
+
import { createLogger, eventLogger } from './utils/logger.js';
|
|
10
|
+
import { getModules } from './utils/modules.js';
|
|
11
|
+
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', '.*'];
|
|
12
|
+
const configPath = flags.config ?? path.join(cwd, 'reciple.yml');
|
|
13
|
+
if (!existsSync(cwd))
|
|
14
|
+
mkdirSync(cwd, { recursive: true });
|
|
15
|
+
if (readdirSync(cwd).filter(f => !micromatch.isMatch(f, allowedFiles)).length && !existsSync(configPath) && !flags.yes) {
|
|
16
|
+
const confirm = await promptConfirm({
|
|
17
|
+
default: false,
|
|
18
|
+
message: 'Would you like to create Reciple config here?'
|
|
19
|
+
});
|
|
20
|
+
if (!confirm)
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
const configParser = await (new Config(configPath)).parseConfig();
|
|
24
|
+
const config = configParser.getConfig();
|
|
25
|
+
const client = new RecipleClient({
|
|
26
|
+
recipleOptions: config,
|
|
27
|
+
...config.client,
|
|
28
|
+
logger: config.logger.enabled ? createLogger(config.logger) : undefined
|
|
29
|
+
});
|
|
30
|
+
client.logger?.info(`Starting Reciple client v${realVersion} - ${new Date()}`);
|
|
31
|
+
eventLogger(client);
|
|
32
|
+
await client.modules.startModules({
|
|
33
|
+
modules: await client.modules.resolveModuleFiles(await getModules(config.modules, file => file.endsWith('.js') || file.endsWith('.mjs') || file.endsWith('.cjs')), config.modules.disableModuleVersionCheck),
|
|
34
|
+
addToModulesCollection: true
|
|
35
|
+
});
|
|
36
|
+
client.once('ready', async () => {
|
|
37
|
+
const loadedModules = await client.modules.loadModules({
|
|
38
|
+
modules: client.modules.modules.toJSON(),
|
|
39
|
+
resolveCommands: true
|
|
40
|
+
});
|
|
41
|
+
client.modules.modules.sweep(m => !loadedModules.some(s => s.id == m.id));
|
|
42
|
+
const unloadModulesAndStopProcess = async (signal) => {
|
|
43
|
+
await client.modules.unloadModules({
|
|
44
|
+
reason: 'ProcessExit',
|
|
45
|
+
modules: client.modules.modules.toJSON(),
|
|
46
|
+
removeCommandsFromClient: false,
|
|
47
|
+
removeFromModulesCollection: true
|
|
48
|
+
});
|
|
49
|
+
client.logger?.warn(`Process exited: ${signal === 'SIGINT' ? 'keyboard interrupt' : signal === 'SIGTERM' ? 'terminate' : signal}`);
|
|
50
|
+
process.exit();
|
|
51
|
+
};
|
|
52
|
+
process.once('SIGINT', signal => unloadModulesAndStopProcess(signal));
|
|
53
|
+
process.once('SIGTERM', signal => unloadModulesAndStopProcess(signal));
|
|
54
|
+
client.on('cacheSweep', () => client.cooldowns.clean());
|
|
55
|
+
await client.commands.registerApplicationCommands();
|
|
56
|
+
client.logger?.warn(`Logged in as ${client.user?.tag} (${client.user?.id})`);
|
|
57
|
+
client.logger?.log(`Loaded ${client.commands.contextMenuCommands.size} context menu commands`);
|
|
58
|
+
client.logger?.log(`Loaded ${client.commands.messageCommands.size} message commands`);
|
|
59
|
+
client.logger?.log(`Loaded ${client.commands.slashCommands.size} slash commands`);
|
|
60
|
+
client.on('interactionCreate', interaction => {
|
|
61
|
+
if (interaction.isContextMenuCommand()) {
|
|
62
|
+
ContextMenuCommandBuilder.execute(client, interaction);
|
|
63
|
+
}
|
|
64
|
+
else if (interaction.isChatInputCommand()) {
|
|
65
|
+
SlashCommandBuilder.execute(client, interaction);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
client.on('messageCreate', message => {
|
|
69
|
+
MessageCommandBuilder.execute(client, message);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
client.login(config.token);
|
|
73
|
+
//# sourceMappingURL=bin.mjs.map
|
package/bin/bin.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.mjs","sourceRoot":"","sources":["../src/bin.mts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpI,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,YAAY,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;AAC3E,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AAEjE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;IAAE,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,IAAI,WAAW,CAAC,G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
1
|
+
import { RecipleConfigOptions } from '@reciple/client';
|
|
2
|
+
import { ClientOptions } from 'discord.js';
|
|
3
|
+
export interface IConfig extends RecipleConfigOptions {
|
|
4
|
+
logger: {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
debugmode: boolean;
|
|
7
|
+
coloredMessages: boolean;
|
|
8
|
+
logToFile: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
logsFolder: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
modules: {
|
|
14
|
+
modulesFolders: string[];
|
|
15
|
+
exclude: string[];
|
|
16
|
+
disableModuleVersionCheck: boolean;
|
|
17
|
+
};
|
|
18
|
+
client: ClientOptions;
|
|
19
|
+
version: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class Config {
|
|
22
|
+
static defaultConfigPath: string;
|
|
23
|
+
config: IConfig | null;
|
|
24
|
+
readonly configPath: string;
|
|
25
|
+
constructor(configPath: string);
|
|
26
|
+
parseConfig(): Promise<this>;
|
|
27
|
+
getConfig(): IConfig;
|
|
28
|
+
askToken(): Promise<string>;
|
|
29
|
+
parseToken(): string | null;
|
|
30
|
+
static defaultConfig(): IConfig;
|
|
31
|
+
static defaultConfigYaml(): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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.Config = void 0;
|
|
7
|
+
const client_1 = require("@reciple/client");
|
|
8
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
11
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
12
|
+
const cli_1 = require("../utils/cli");
|
|
13
|
+
dotenv_1.default.config({
|
|
14
|
+
path: cli_1.flags.env ? fallout_utility_1.path.resolve(cli_1.flags.env) : fallout_utility_1.path.join(cli_1.cwd, '.env')
|
|
15
|
+
});
|
|
16
|
+
class Config {
|
|
17
|
+
static defaultConfigPath = fallout_utility_1.path.join(__dirname, '../../static/config.yml');
|
|
18
|
+
config = null;
|
|
19
|
+
configPath;
|
|
20
|
+
constructor(configPath) {
|
|
21
|
+
if (!configPath)
|
|
22
|
+
throw new Error('Config path is not defined');
|
|
23
|
+
this.configPath = configPath;
|
|
24
|
+
}
|
|
25
|
+
async parseConfig() {
|
|
26
|
+
if (!(0, fs_1.existsSync)(this.configPath)) {
|
|
27
|
+
let configYaml = (0, fallout_utility_1.replaceAll)(Config.defaultConfigYaml(), 'VERSION', client_1.version);
|
|
28
|
+
let configData = yaml_1.default.parse(configYaml);
|
|
29
|
+
if (configData.token === 'TOKEN') {
|
|
30
|
+
configData.token = await this.askToken() || 'TOKEN';
|
|
31
|
+
configYaml = (0, fallout_utility_1.replaceAll)(configYaml, 'token: TOKEN', `token: ${configData.token}`);
|
|
32
|
+
}
|
|
33
|
+
(0, fs_1.writeFileSync)(this.configPath, configYaml, 'utf-8');
|
|
34
|
+
this.config = configData;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
this.config = yaml_1.default.parse((0, fs_1.readFileSync)(this.configPath, 'utf-8'));
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
getConfig() {
|
|
41
|
+
if (!this.config)
|
|
42
|
+
throw new Error(`Config is not parsed`);
|
|
43
|
+
this.config.token = this.parseToken() || 'TOKEN';
|
|
44
|
+
return this.config;
|
|
45
|
+
}
|
|
46
|
+
async askToken() {
|
|
47
|
+
return (await import('@inquirer/password')).default({
|
|
48
|
+
message: `Bot token`,
|
|
49
|
+
mask: '*',
|
|
50
|
+
validate: value => !value.length ? 'Enter a valid bot token' : true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
parseToken() {
|
|
54
|
+
let token = cli_1.flags.token || this.config?.token || null;
|
|
55
|
+
if (!token)
|
|
56
|
+
return token;
|
|
57
|
+
const env = String(token).split(':');
|
|
58
|
+
if (env.length !== 2 || env[0].toLowerCase() !== 'env')
|
|
59
|
+
return token;
|
|
60
|
+
return process.env[env[1]] ?? null;
|
|
61
|
+
}
|
|
62
|
+
static defaultConfig() {
|
|
63
|
+
return yaml_1.default.parse(this.defaultConfigYaml());
|
|
64
|
+
}
|
|
65
|
+
static defaultConfigYaml() {
|
|
66
|
+
if (!(0, fs_1.existsSync)(this.defaultConfigPath))
|
|
67
|
+
throw new Error(`Default config file does not exists: ${this.defaultConfigPath}`);
|
|
68
|
+
return (0, fs_1.readFileSync)(this.defaultConfigPath, 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.Config = Config;
|
|
72
|
+
//# sourceMappingURL=Config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Config.js","sourceRoot":"","sources":["../../src/classes/Config.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAgE;AAChE,qDAAmD;AACnD,2BAA6D;AAE7D,gDAAuB;AACvB,oDAA4B;AAC5B,sCAA0C;AAE1C,gBAAM,CAAC,MAAM,CAAC;IACV,IAAI,EAAE,WAAK,CAAC,GAAG,CAAC,CAAC,CAAC,sBAAI,CAAC,OAAO,CAAC,WAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,sBAAI,CAAC,IAAI,CAAC,SAAG,EAAE,MAAM,CAAC;CACrE,CAAC,CAAC;AAqBH,MAAa,MAAM;IACR,MAAM,CAAC,iBAAiB,GAAW,sBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;IACnF,MAAM,GAAiB,IAAI,CAAC;IAC1B,UAAU,CAAS;IAE5B,YAAY,UAAkB;QAC1B,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC/D,IAAI,CAAC,UAAU,GAAG,UAAU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,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI;SACtE,CAAC,CAAC;IACP,CAAC;IAEM,UAAU;QACb,IAAI,KAAK,GAAG,WAAK,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;QACtD,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAEzB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAErE,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,aAAa;QACvB,OAAO,cAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC/C,CAAC;IAEM,MAAM,CAAC,iBAAiB;QAC3B,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,iBAAiB,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAC3H,OAAO,IAAA,iBAAY,EAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;;AA/DL,wBAgEC"}
|
package/bin/esm.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
package/{dist/lib → bin}/esm.mjs
RENAMED
|
File without changes
|
package/bin/esm.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../src/esm.mts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/bin/index.d.ts
ADDED
package/bin/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@reciple/client"), exports);
|
|
18
|
+
__exportStar(require("./classes/Config"), exports);
|
|
19
|
+
__exportStar(require("./utils/cli"), exports);
|
|
20
|
+
__exportStar(require("./utils/logger"), exports);
|
|
21
|
+
__exportStar(require("./utils/modules"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/bin/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,mDAAiC;AACjC,8CAA4B;AAC5B,iDAA+B;AAC/B,kDAAgC"}
|
package/bin/utils/cli.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cwd = exports.flags = exports.command = void 0;
|
|
4
|
+
const client_1 = require("@reciple/client");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
7
|
+
exports.command = new commander_1.Command()
|
|
8
|
+
.name('reciple')
|
|
9
|
+
.description('Reciple.js - Discord.js handler cli')
|
|
10
|
+
.version(`v${client_1.realVersion}`, '-v, --version')
|
|
11
|
+
.argument('[cwd]', 'Change the current working directory')
|
|
12
|
+
.option('-t, --token <token>', 'Replace used bot token')
|
|
13
|
+
.option('-c, --config <config>', 'Change path to config file')
|
|
14
|
+
.option('-D, --debugmode', 'Enable debug mode')
|
|
15
|
+
.option('-y, --yes', 'Agree to all Reciple confirmation prompts')
|
|
16
|
+
.option('--env', '.env file location')
|
|
17
|
+
.parse();
|
|
18
|
+
exports.flags = exports.command.opts();
|
|
19
|
+
exports.cwd = exports.command.args[0] ? fallout_utility_1.path.resolve(exports.command.args[0]) : process.cwd();
|
|
20
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAC9C,yCAAoC;AACpC,qDAAuC;AAE1B,QAAA,OAAO,GAAG,IAAI,mBAAO,EAAE;KAC/B,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,qCAAqC,CAAC;KAClD,OAAO,CAAC,IAAI,oBAAW,EAAE,EAAE,eAAe,CAAC;KAC3C,QAAQ,CAAC,OAAO,EAAE,sCAAsC,CAAC;KACzD,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,CAAC;KACvD,MAAM,CAAC,uBAAuB,EAAE,4BAA4B,CAAC;KAC7D,MAAM,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;KAC9C,MAAM,CAAC,WAAW,EAAE,2CAA2C,CAAC;KAChE,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC;KACrC,KAAK,EAAE,CAAC;AAEA,QAAA,KAAK,GAAG,eAAO,CAAC,IAAI,EAAE,CAAC;AACvB,QAAA,GAAG,GAAG,eAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAI,CAAC,OAAO,CAAC,eAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IConfig } from '../classes/Config';
|
|
2
|
+
import { Logger, LoggerLevel } from 'fallout-utility';
|
|
3
|
+
import { RecipleClient } from '..';
|
|
4
|
+
export declare function formatLogMessage(message: string, logger: Logger, config: IConfig['logger'], level: LoggerLevel): string;
|
|
5
|
+
export declare function createLogger(config: IConfig['logger']): Logger;
|
|
6
|
+
export declare function eventLogger(client: RecipleClient): void;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.eventLogger = exports.createLogger = exports.formatLogMessage = void 0;
|
|
7
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const cli_1 = require("./cli");
|
|
10
|
+
function formatLogMessage(message, logger, config, level) {
|
|
11
|
+
const color = (msg) => {
|
|
12
|
+
if (!config.coloredMessages || level === fallout_utility_1.LoggerLevel.INFO)
|
|
13
|
+
return msg;
|
|
14
|
+
switch (level) {
|
|
15
|
+
case fallout_utility_1.LoggerLevel.WARN:
|
|
16
|
+
return chalk_1.default.yellow(msg);
|
|
17
|
+
case fallout_utility_1.LoggerLevel.ERROR:
|
|
18
|
+
return chalk_1.default.red(msg);
|
|
19
|
+
case fallout_utility_1.LoggerLevel.DEBUG:
|
|
20
|
+
return chalk_1.default.cyan(msg);
|
|
21
|
+
default:
|
|
22
|
+
return msg;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return `[${color(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${color((logger.name ? logger.name + '/' : '') + fallout_utility_1.LoggerLevel[level])}] ${color(message)}`;
|
|
26
|
+
}
|
|
27
|
+
exports.formatLogMessage = formatLogMessage;
|
|
28
|
+
function createLogger(config) {
|
|
29
|
+
const logger = new fallout_utility_1.Logger({
|
|
30
|
+
enableDebugmode: config.debugmode === true,
|
|
31
|
+
forceEmitLogEvents: true,
|
|
32
|
+
name: 'Client',
|
|
33
|
+
formatMessageLines: {
|
|
34
|
+
[fallout_utility_1.LoggerLevel.INFO]: (message, logger) => formatLogMessage(message, logger, config, fallout_utility_1.LoggerLevel.INFO),
|
|
35
|
+
[fallout_utility_1.LoggerLevel.WARN]: (message, logger) => formatLogMessage(message, logger, config, fallout_utility_1.LoggerLevel.WARN),
|
|
36
|
+
[fallout_utility_1.LoggerLevel.ERROR]: (message, logger) => formatLogMessage(message, logger, config, fallout_utility_1.LoggerLevel.ERROR),
|
|
37
|
+
[fallout_utility_1.LoggerLevel.DEBUG]: (message, logger) => formatLogMessage(message, logger, config, fallout_utility_1.LoggerLevel.DEBUG),
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (config.logToFile.enabled)
|
|
41
|
+
logger.logToFile(fallout_utility_1.path.join(cli_1.cwd, config.logToFile.logsFolder, 'latest.log'));
|
|
42
|
+
return logger;
|
|
43
|
+
}
|
|
44
|
+
exports.createLogger = createLogger;
|
|
45
|
+
function eventLogger(client) {
|
|
46
|
+
client.on('recipleDebug', debug => client.logger?.debug(debug));
|
|
47
|
+
client.modules.on('resolveModuleFileError', (file, error) => client.logger?.err(`Failed to resolve module '${file}': `, error));
|
|
48
|
+
client.modules.on('preStartModule', (module_) => client.logger?.debug(`Starting module '${module_.displayName}'`));
|
|
49
|
+
client.modules.on('postStartModule', (module_) => client.logger?.log(`Started module '${module_.displayName}'`));
|
|
50
|
+
client.modules.on('startModuleFailed', (module_) => client.logger?.error(`Failed to load module '${module_.displayName}': Returned false`));
|
|
51
|
+
client.modules.on('startModuleError', (module_, err) => client.logger?.error(`An error occured while starting module '${module_.displayName}': `, err));
|
|
52
|
+
client.modules.on('preLoadModule', (module_) => client.logger?.debug(`Loading module '${module_.displayName}'`));
|
|
53
|
+
client.modules.on('postLoadModule', (module_) => client.logger?.log(`Loaded module '${module_.displayName}'`));
|
|
54
|
+
client.modules.on('loadModuleError', (module_, err) => client.logger?.error(`An error occured while loading module: '${module_.displayName}': `, err));
|
|
55
|
+
client.modules.on('preUnloadModule', (module_) => client.logger?.debug(`Unloading module '${module_.displayName}'`));
|
|
56
|
+
client.modules.on('postUnloadModule', (module_) => client.logger?.log(`Unloaded module '${module_.displayName}'`));
|
|
57
|
+
client.modules.on('unloadModuleError', (module_, err) => client.logger?.error(`An error occured while unloading module '${module_.displayName}'`, err));
|
|
58
|
+
client.on('recipleRegisterApplicationCommands', (commands, guild) => client.logger?.log(`Register ${commands?.size || 0} application commands ${guild ? ' to ' + guild : 'globally'}`));
|
|
59
|
+
}
|
|
60
|
+
exports.eventLogger = eventLogger;
|
|
61
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;AACA,qDAA4D;AAC5D,kDAA0B;AAE1B,+BAA4B;AAG5B,SAAgB,gBAAgB,CAAC,OAAe,EAAE,MAAc,EAAE,MAAyB,EAAE,KAAkB;IAC3G,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,EAAE;QAC1B,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,KAAK,KAAK,6BAAW,CAAC,IAAI;YAAE,OAAO,GAAG,CAAC;QAEtE,QAAQ,KAAK,EAAE;YACX,KAAK,6BAAW,CAAC,IAAI;gBACjB,OAAO,eAAK,CAAC,MAAM,CA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,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,4CAA4C,OAAO,CAAC,WAAW,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAExJ,MAAM,CAAC,EAAE,CAAC,oCAAoC,EAAE,CAAC,QAAgD,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,QAAQ,EAAE,IAAI,IAAI,CAAC,yBAAyB,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AACpO,CAAC;AAnBD,kCAmBC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModules = void 0;
|
|
4
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
5
|
+
const cli_1 = require("./cli");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
async function getModules(config, filter) {
|
|
8
|
+
const modules = [];
|
|
9
|
+
const { globby, isDynamicPattern } = await import('globby');
|
|
10
|
+
for (const folder of config.modulesFolders) {
|
|
11
|
+
const dir = fallout_utility_1.path.isAbsolute(folder) ? folder : fallout_utility_1.path.join(cli_1.cwd, folder);
|
|
12
|
+
if (isDynamicPattern(dir)) {
|
|
13
|
+
modules.push(...await getModules({
|
|
14
|
+
...config,
|
|
15
|
+
modulesFolders: await globby(dir, {
|
|
16
|
+
cwd: cli_1.cwd,
|
|
17
|
+
gitignore: true,
|
|
18
|
+
ignore: config.exclude.map(p => fallout_utility_1.path.isAbsolute(p) ? p : fallout_utility_1.path.join(cli_1.cwd, p)),
|
|
19
|
+
onlyDirectories: true,
|
|
20
|
+
absolute: true
|
|
21
|
+
})
|
|
22
|
+
}));
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
26
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
27
|
+
if (!(0, fs_1.lstatSync)(dir).isDirectory())
|
|
28
|
+
continue;
|
|
29
|
+
const files = (0, fs_1.readdirSync)(dir).map(file => fallout_utility_1.path.join(dir, file));
|
|
30
|
+
modules.push(...files.filter(file => (filter ? filter(file) : file.endsWith('.js'))));
|
|
31
|
+
}
|
|
32
|
+
return modules;
|
|
33
|
+
}
|
|
34
|
+
exports.getModules = getModules;
|
|
35
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/utils/modules.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAElD,+BAA4B;AAC5B,2BAAmE;AAE5D,KAAK,UAAU,UAAU,CAAC,MAA0B,EAAE,MAAiD;IAC1G,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE5D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,cAAc,EAAE;QACxC,MAAM,GAAG,GAAG,sBAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAI,CAAC,IAAI,CAAC,SAAG,EAAE,MAAM,CAAC,CAAC;QAEtE,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE;YAEvB,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,UAAU,CAAC;gBAC7B,GAAG,MAAM;gBACT,cAAc,EAAE,MAAM,MAAM,CAAC,GAAG,EAAE;oBAC9B,GAAG,EAAH,SAAG;oBACH,SAAS,EAAE,IAAI;oBACf,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAI,CAAC,IAAI,CAAC,SAAG,EAAE,CAAC,CAAC,CAAC;oBAC3E,eAAe,EAAE,IAAI;oBACrB,QAAQ,EAAE,IAAI;iBACjB,CAAC;aACL,CAAC,CAAC,CAAC;YACJ,SAAS;SACZ;QAED,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC;YAAE,IAAA,cAAS,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAA,cAAS,EAAC,GAAG,CAAC,CAAC,WAAW,EAAE;YAAE,SAAS;QAE5C,MAAM,KAAK,GAAG,IAAA,gBAAW,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,sBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KACzF;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AA9BD,gCA8BC"}
|
package/package.json
CHANGED
|
@@ -1,87 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"
|
|
3
|
+
"description": "Reciple is a Discord.js handler",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"types": "./dist/types/index.d.ts",
|
|
11
|
-
"description": "A simple Discord.js handler that just works",
|
|
12
|
-
"homepage": "https://reciple.js.org",
|
|
13
|
-
"bin": {
|
|
14
|
-
"reciple": "./dist/lib/bin.mjs"
|
|
15
|
-
},
|
|
5
|
+
"version": "7.0.0-dev.5",
|
|
6
|
+
"main": "./bin/index.js",
|
|
7
|
+
"module": "./bin/esm.mjs",
|
|
8
|
+
"types": "./bin/index.d.ts",
|
|
9
|
+
"bin": "./bin/bin.mjs",
|
|
16
10
|
"exports": {
|
|
17
11
|
".": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
"require": {
|
|
23
|
-
"types": "./dist/types/index.d.ts",
|
|
24
|
-
"default": "./dist/lib/index.js"
|
|
25
|
-
}
|
|
12
|
+
"types": "./bin/index.d.ts",
|
|
13
|
+
"import": "./bin/esm.mjs",
|
|
14
|
+
"require": "./bin/index.js"
|
|
26
15
|
}
|
|
27
16
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"Reciple"
|
|
32
|
-
],
|
|
33
|
-
"contributors": [
|
|
34
|
-
"GhexterCortes"
|
|
35
|
-
],
|
|
36
|
-
"bugs": {
|
|
37
|
-
"url": "https://github.com/FalloutStudios/reciple/issues"
|
|
38
|
-
},
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=16.9.0"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"clean": "npx rimraf ./bin",
|
|
19
|
+
"build": "npm run clean && npx tsc"
|
|
41
20
|
},
|
|
42
|
-
"workspaces": [
|
|
43
|
-
"test"
|
|
44
|
-
],
|
|
45
21
|
"files": [
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"LICENSE",
|
|
49
|
-
"README.md"
|
|
22
|
+
"bin",
|
|
23
|
+
"static"
|
|
50
24
|
],
|
|
51
|
-
"scripts": {
|
|
52
|
-
"format": "npx prettier --write src",
|
|
53
|
-
"clean": "npx rimraf dist",
|
|
54
|
-
"build": "npm run clean && npx tsc",
|
|
55
|
-
"build:publish": "npm run format && npm run build && npm run docs && npm publish",
|
|
56
|
-
"build:publish-dev": "npm run format && npm run build && npm publish --tag dev",
|
|
57
|
-
"test": "npm run build && npm install && npm run start -w test",
|
|
58
|
-
"docs": "npx docgen --typescript true -c ./docs/index.json -o ./docs/docs.json -i src/index.ts",
|
|
59
|
-
"watch": "npx tsc --watch --noEmit"
|
|
60
|
-
},
|
|
61
|
-
"repository": {
|
|
62
|
-
"type": "git",
|
|
63
|
-
"url": "git+https://github.com/FalloutStudios/reciple.git"
|
|
64
|
-
},
|
|
65
25
|
"dependencies": {
|
|
26
|
+
"@inquirer/confirm": "^0.0.28-alpha.0",
|
|
27
|
+
"@inquirer/password": "^0.0.28-alpha.0",
|
|
28
|
+
"@reciple/client": "^7.0.0-dev.1",
|
|
66
29
|
"chalk": "4.1.2",
|
|
67
|
-
"commander": "^
|
|
30
|
+
"commander": "^10.0.0",
|
|
68
31
|
"dotenv": "^16.0.3",
|
|
69
|
-
"fallout-utility": "^1.
|
|
32
|
+
"fallout-utility": "^2.1.3",
|
|
33
|
+
"globby": "^13.1.3",
|
|
70
34
|
"micromatch": "^4.0.5",
|
|
71
|
-
"
|
|
72
|
-
"yaml": "^2.1.1"
|
|
35
|
+
"yaml": "^2.2.1"
|
|
73
36
|
},
|
|
74
37
|
"devDependencies": {
|
|
75
|
-
"@discordjs/docgen": "^0.12.1",
|
|
76
38
|
"@types/micromatch": "^4.0.2",
|
|
77
|
-
"
|
|
78
|
-
"@types/semver": "^7.3.13",
|
|
79
|
-
"discord.js": "^14.7.0",
|
|
80
|
-
"prettier": "^2.8.0",
|
|
81
|
-
"rimraf": "^3.0.2",
|
|
82
|
-
"typescript": "^4.9.3"
|
|
39
|
+
"discord.js": "^14.7.1"
|
|
83
40
|
},
|
|
84
41
|
"peerDependencies": {
|
|
85
|
-
"discord.js": "^14.
|
|
86
|
-
}
|
|
42
|
+
"discord.js": "^14.7.1"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "98705670840da34462488aaaa26eccd3b10265e4"
|
|
87
45
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# The bot token
|
|
2
|
+
# You can directly set the bot token as value or use token from env
|
|
3
|
+
# To use token from env set the value like this:
|
|
4
|
+
# token: env:TOKEN
|
|
5
|
+
token: TOKEN
|
|
6
|
+
|
|
7
|
+
# Commands Config
|
|
8
|
+
commands:
|
|
9
|
+
contextMenuCommand:
|
|
10
|
+
# If false, the client will ignore this type of command when executed
|
|
11
|
+
enabled: true
|
|
12
|
+
# Enable user command cooldowns if available
|
|
13
|
+
enableCooldown: true
|
|
14
|
+
# Command register config
|
|
15
|
+
registerCommands:
|
|
16
|
+
# Allow commands to be registered globally
|
|
17
|
+
registerGlobally: true
|
|
18
|
+
# Allow commands to be registered a given guilds/servers
|
|
19
|
+
registerToGuilds: []
|
|
20
|
+
# If enabled, the client will accept replied interactions of this type
|
|
21
|
+
acceptRepliedInteractions: false
|
|
22
|
+
slashCommand:
|
|
23
|
+
# If false, the client will ignore this type of command when executed
|
|
24
|
+
enabled: true
|
|
25
|
+
# Enable user command cooldowns if available
|
|
26
|
+
enableCooldown: true
|
|
27
|
+
# Command register config
|
|
28
|
+
registerCommands:
|
|
29
|
+
# Allow commands to be registered globally
|
|
30
|
+
registerGlobally: true
|
|
31
|
+
# Allow commands to be registered a given guilds/servers
|
|
32
|
+
registerToGuilds: []
|
|
33
|
+
# If enabled, the client will accept replied interactions of this type
|
|
34
|
+
acceptRepliedInteractions: false
|
|
35
|
+
messageCommand:
|
|
36
|
+
# If false, the client will ignore this type of command when executed
|
|
37
|
+
enabled: true
|
|
38
|
+
# Enable user command cooldowns if available
|
|
39
|
+
enableCooldown: true
|
|
40
|
+
# String separator for command options
|
|
41
|
+
commandArgumentSeparator: ' '
|
|
42
|
+
# Command prefix
|
|
43
|
+
prefix: '!'
|
|
44
|
+
additionalApplicationCommands:
|
|
45
|
+
# Command register config
|
|
46
|
+
registerCommands:
|
|
47
|
+
# Allow commands to be registered globally
|
|
48
|
+
registerGlobally: true
|
|
49
|
+
# Allow commands to be registered a given guilds/servers
|
|
50
|
+
registerToGuilds: []
|
|
51
|
+
|
|
52
|
+
# Application commands register config
|
|
53
|
+
applicationCommandRegister:
|
|
54
|
+
# Wether allow all application commands to be registered globally
|
|
55
|
+
# This ignores their specific configs
|
|
56
|
+
allowRegisterGlobally: true
|
|
57
|
+
# Wether allow all application commands to be registered to guilds
|
|
58
|
+
# This ignores their specific configs
|
|
59
|
+
allowRegisterOnGuilds: true
|
|
60
|
+
# Register empty command list
|
|
61
|
+
registerEmptyCommands: true
|
|
62
|
+
|
|
63
|
+
# Logger config
|
|
64
|
+
logger:
|
|
65
|
+
# Enables client logger
|
|
66
|
+
enabled: true
|
|
67
|
+
# Enables logger debug mode
|
|
68
|
+
debugmode: false
|
|
69
|
+
# Enables colored console logs
|
|
70
|
+
coloredMessages: true
|
|
71
|
+
# File file config
|
|
72
|
+
logToFile:
|
|
73
|
+
# Enables log file
|
|
74
|
+
enabled: true
|
|
75
|
+
# Sets the log file folder
|
|
76
|
+
logsFolder: './logs'
|
|
77
|
+
|
|
78
|
+
# Modules config
|
|
79
|
+
modules:
|
|
80
|
+
# Reciple modules folders
|
|
81
|
+
# You can add multiple folders by adding the folder path or using glob patterns
|
|
82
|
+
modulesFolders: ['./modules']
|
|
83
|
+
# Excluded files or folders
|
|
84
|
+
# You can add the file/folder name or use glob patterns
|
|
85
|
+
exclude: []
|
|
86
|
+
# If false, the client will still load unsupported modules
|
|
87
|
+
disableModuleVersionCheck: false
|
|
88
|
+
|
|
89
|
+
# Discord.js client options
|
|
90
|
+
client:
|
|
91
|
+
intents:
|
|
92
|
+
- 'Guilds'
|
|
93
|
+
- 'GuildMessages'
|
|
94
|
+
- 'MessageContent'
|
|
95
|
+
|
|
96
|
+
# Don't change this value
|
|
97
|
+
version: ^VERSION
|