reciple 6.0.0-dev.8 → 6.0.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 +1 -2
- package/dist/lib/bin.mjs +70 -0
- package/dist/lib/bin.mjs.map +1 -0
- package/dist/lib/esm.mjs +2 -0
- package/dist/lib/esm.mjs.map +1 -0
- package/dist/{cjs → lib}/index.js +17 -17
- package/dist/lib/index.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/RecipleClient.js +40 -31
- package/dist/lib/reciple/classes/RecipleClient.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/RecipleConfig.js +11 -10
- package/dist/lib/reciple/classes/RecipleConfig.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/RecipleModule.js +63 -20
- package/dist/lib/reciple/classes/RecipleModule.js.map +1 -0
- package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +310 -0
- package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandOptionBuilder.js +55 -13
- package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/builders/SlashCommandBuilder.js +43 -15
- package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/managers/ApplicationCommandManager.js +51 -10
- package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/managers/CommandCooldownManager.js +1 -1
- package/dist/lib/reciple/classes/managers/CommandCooldownManager.js.map +1 -0
- package/dist/{cjs/reciple/classes/managers/ClientCommandManager.js → lib/reciple/classes/managers/CommandManager.js} +18 -16
- package/dist/lib/reciple/classes/managers/CommandManager.js.map +1 -0
- package/dist/{cjs → lib}/reciple/classes/managers/MessageCommandOptionManager.js +1 -0
- package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js.map +1 -0
- package/dist/{cjs/reciple/classes/managers/ClientModuleManager.js → lib/reciple/classes/managers/ModuleManager.js} +78 -64
- package/dist/lib/reciple/classes/managers/ModuleManager.js.map +1 -0
- package/dist/{cjs → lib}/reciple/flags.js +4 -3
- package/dist/lib/reciple/flags.js.map +1 -0
- package/dist/{cjs → lib}/reciple/permissions.js +1 -0
- package/dist/lib/reciple/permissions.js.map +1 -0
- package/dist/lib/reciple/types/builders.js +12 -0
- package/dist/lib/reciple/types/builders.js.map +1 -0
- package/dist/{cjs → lib}/reciple/types/commands.js +7 -6
- package/dist/lib/reciple/types/commands.js.map +1 -0
- package/dist/{cjs → lib}/reciple/types/paramOptions.js +1 -0
- package/dist/lib/reciple/types/paramOptions.js.map +1 -0
- package/dist/{cjs → lib}/reciple/util.js +14 -8
- package/dist/lib/reciple/util.js.map +1 -0
- package/dist/{cjs → lib}/reciple/version.js +1 -1
- package/dist/lib/reciple/version.js.map +1 -0
- package/dist/types/{bin.d.ts → bin.d.mts} +1 -0
- package/dist/types/bin.d.mts.map +1 -0
- package/dist/types/esm.d.mts +2 -0
- package/dist/types/esm.d.mts.map +1 -0
- package/dist/types/index.d.ts +17 -17
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/reciple/classes/RecipleClient.d.ts +22 -8
- package/dist/types/reciple/classes/RecipleClient.d.ts.map +1 -0
- package/dist/types/reciple/classes/RecipleConfig.d.ts +4 -2
- package/dist/types/reciple/classes/RecipleConfig.d.ts.map +1 -0
- package/dist/types/reciple/classes/RecipleModule.d.ts +37 -5
- package/dist/types/reciple/classes/RecipleModule.d.ts.map +1 -0
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +67 -27
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts.map +1 -0
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +18 -7
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts.map +1 -0
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +23 -12
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts.map +1 -0
- package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +45 -6
- package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts.map +1 -0
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +3 -2
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts.map +1 -0
- package/dist/types/reciple/classes/managers/CommandManager.d.ts +35 -0
- package/dist/types/reciple/classes/managers/CommandManager.d.ts.map +1 -0
- package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +2 -1
- package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts.map +1 -0
- package/dist/types/reciple/classes/managers/ModuleManager.d.ts +50 -0
- package/dist/types/reciple/classes/managers/ModuleManager.d.ts.map +1 -0
- package/dist/types/reciple/flags.d.ts +2 -1
- package/dist/types/reciple/flags.d.ts.map +1 -0
- package/dist/types/reciple/permissions.d.ts +3 -6
- package/dist/types/reciple/permissions.d.ts.map +1 -0
- package/dist/types/reciple/types/builders.d.ts +29 -20
- package/dist/types/reciple/types/builders.d.ts.map +1 -0
- package/dist/types/reciple/types/commands.d.ts +19 -18
- package/dist/types/reciple/types/commands.d.ts.map +1 -0
- package/dist/types/reciple/types/paramOptions.d.ts +80 -3
- package/dist/types/reciple/types/paramOptions.d.ts.map +1 -0
- package/dist/types/reciple/util.d.ts +9 -2
- package/dist/types/reciple/util.d.ts.map +1 -0
- package/dist/types/reciple/version.d.ts +1 -0
- package/dist/types/reciple/version.d.ts.map +1 -0
- package/package.json +47 -37
- package/resource/reciple.yml +25 -22
- package/dist/cjs/bin.js +0 -52
- package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +0 -242
- package/dist/cjs/reciple/types/builders.js +0 -11
- package/dist/types/reciple/classes/managers/ClientCommandManager.d.ts +0 -37
- package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +0 -19
- package/docs/README.md +0 -1
|
@@ -23,3 +23,4 @@ export declare function parseVersion(ver: string): semver.SemVer | null;
|
|
|
23
23
|
* @param supportedVersion Version to match given version range
|
|
24
24
|
*/
|
|
25
25
|
export declare function isSupportedVersion(versionRange: string, supportedVersion?: string): boolean;
|
|
26
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/reciple/version.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,OAAO,QAA+D,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,UAAU,KAA2C,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,WAEzC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,wBAIvC;AACD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,WAOjF"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"
|
|
4
|
-
"bin": "./dist/cjs/bin.js",
|
|
3
|
+
"type": "commonjs",
|
|
5
4
|
"license": "GPL-3.0",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"module": "./dist/mjs/index.js",
|
|
5
|
+
"engineStrict": true,
|
|
6
|
+
"version": "6.0.0",
|
|
9
7
|
"author": "FalloutStudios",
|
|
10
|
-
"
|
|
8
|
+
"main": "./dist/lib/index.js",
|
|
9
|
+
"module": "./dist/lib/esm.mjs",
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"description": "A simple Discord.js handler that just works",
|
|
11
12
|
"homepage": "https://reciple.js.org",
|
|
13
|
+
"bin": {
|
|
14
|
+
"reciple": "./dist/lib/bin.mjs"
|
|
15
|
+
},
|
|
12
16
|
"exports": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"default": "./dist/lib/esm.mjs"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
24
|
+
"default": "./dist/lib/index.js"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
16
27
|
},
|
|
17
28
|
"keywords": [
|
|
18
29
|
"Discord",
|
|
@@ -25,53 +36,52 @@
|
|
|
25
36
|
"bugs": {
|
|
26
37
|
"url": "https://github.com/FalloutStudios/reciple/issues"
|
|
27
38
|
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"format": "yarn prettier --write src",
|
|
30
|
-
"clean": "yarn exec rimraf dist",
|
|
31
|
-
"build": "yarn clean && yarn exec tsc",
|
|
32
|
-
"build:publish": "yarn format && yarn build && yarn docs && yarn npm publish",
|
|
33
|
-
"build:publish-dev": "yarn format && yarn build && yarn npm publish --tag dev",
|
|
34
|
-
"test": "yarn build && yarn workspace test start",
|
|
35
|
-
"docs": "yarn exec docgen --typescript true -c ./docs/index.json -o ./docs/docs.json -i src/index.ts",
|
|
36
|
-
"watch": "yarn exec tsc --watch --noEmit"
|
|
37
|
-
},
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/FalloutStudios/reciple.git"
|
|
41
|
-
},
|
|
42
|
-
"engineStrict": true,
|
|
43
39
|
"engines": {
|
|
44
40
|
"node": ">=16.9.0"
|
|
45
41
|
},
|
|
42
|
+
"workspaces": [
|
|
43
|
+
"test"
|
|
44
|
+
],
|
|
46
45
|
"files": [
|
|
47
46
|
"dist",
|
|
48
47
|
"resource",
|
|
49
48
|
"LICENSE",
|
|
50
49
|
"README.md"
|
|
51
50
|
],
|
|
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
|
+
},
|
|
52
65
|
"dependencies": {
|
|
53
66
|
"chalk": "4.1.2",
|
|
54
67
|
"commander": "^9.4.1",
|
|
55
68
|
"dotenv": "^16.0.3",
|
|
56
|
-
"fallout-utility": "^1.5.
|
|
69
|
+
"fallout-utility": "^1.5.17",
|
|
70
|
+
"micromatch": "^4.0.5",
|
|
57
71
|
"semver": "^7.3.7",
|
|
58
|
-
"wildcard-match": "^5.1.2",
|
|
59
72
|
"yaml": "^2.1.1"
|
|
60
73
|
},
|
|
61
74
|
"devDependencies": {
|
|
62
75
|
"@discordjs/docgen": "^0.12.1",
|
|
63
|
-
"@types/
|
|
64
|
-
"@types/
|
|
65
|
-
"
|
|
66
|
-
"
|
|
76
|
+
"@types/micromatch": "^4.0.2",
|
|
77
|
+
"@types/node": "^18.11.9",
|
|
78
|
+
"@types/semver": "^7.3.13",
|
|
79
|
+
"discord.js": "^14.7.0",
|
|
80
|
+
"prettier": "^2.8.0",
|
|
67
81
|
"rimraf": "^3.0.2",
|
|
68
|
-
"typescript": "^4.
|
|
82
|
+
"typescript": "^4.9.3"
|
|
69
83
|
},
|
|
70
84
|
"peerDependencies": {
|
|
71
85
|
"discord.js": "^14.5.0"
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
"test"
|
|
75
|
-
],
|
|
76
|
-
"packageManager": "yarn@3.2.2"
|
|
77
|
-
}
|
|
86
|
+
}
|
|
87
|
+
}
|
package/resource/reciple.yml
CHANGED
|
@@ -4,20 +4,24 @@ token: TOKEN
|
|
|
4
4
|
|
|
5
5
|
# Commands options
|
|
6
6
|
commands:
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
# enable
|
|
7
|
+
# Interaction command options
|
|
8
|
+
slashCommand:
|
|
9
|
+
# enable interaction commands
|
|
10
10
|
enabled: true
|
|
11
|
-
# command prefix
|
|
12
|
-
prefix: '!'
|
|
13
11
|
# reply when an error occured
|
|
14
12
|
replyOnError: false
|
|
15
13
|
# enable the use of command cooldowns
|
|
16
14
|
enableCooldown: true
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
|
|
15
|
+
# register interaction commands on bot ready
|
|
16
|
+
registerCommands: true
|
|
17
|
+
# allow register empty list of application commands
|
|
18
|
+
allowRegisterEmptyCommandList: true
|
|
19
|
+
# set required permissions for interaction commands
|
|
20
|
+
setRequiredPermissions: true
|
|
21
|
+
# accept replied or deffered command interaction
|
|
22
|
+
acceptRepliedInteractions: false
|
|
23
|
+
# register commands to specific guild(s) empty to make it global
|
|
24
|
+
guilds: []
|
|
21
25
|
# overwrite command permissions
|
|
22
26
|
permissions:
|
|
23
27
|
# enable overwriten command permissions
|
|
@@ -27,22 +31,20 @@ commands:
|
|
|
27
31
|
permissions:
|
|
28
32
|
- Administrator
|
|
29
33
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
# enable
|
|
34
|
+
# message command options
|
|
35
|
+
messageCommand:
|
|
36
|
+
# enable message commands
|
|
33
37
|
enabled: true
|
|
38
|
+
# command prefix
|
|
39
|
+
prefix: '!'
|
|
34
40
|
# reply when an error occured
|
|
35
41
|
replyOnError: false
|
|
36
42
|
# enable the use of command cooldowns
|
|
37
43
|
enableCooldown: true
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
# accept replied or deffered command interaction
|
|
43
|
-
acceptRepliedInteractions: false
|
|
44
|
-
# register commands to specific guild(s) empty to make it global
|
|
45
|
-
guilds: []
|
|
44
|
+
# allow executing commands via aliases
|
|
45
|
+
allowCommandAlias: true
|
|
46
|
+
# command argument separator
|
|
47
|
+
commandArgumentSeparator: ' '
|
|
46
48
|
# overwrite command permissions
|
|
47
49
|
permissions:
|
|
48
50
|
# enable overwriten command permissions
|
|
@@ -52,7 +54,6 @@ commands:
|
|
|
52
54
|
permissions:
|
|
53
55
|
- Administrator
|
|
54
56
|
|
|
55
|
-
|
|
56
57
|
# Logger options
|
|
57
58
|
fileLogging:
|
|
58
59
|
# enable console output to file
|
|
@@ -93,7 +94,9 @@ messages:
|
|
|
93
94
|
ephemeral: true
|
|
94
95
|
|
|
95
96
|
# Ignored Files
|
|
96
|
-
ignoredFiles:
|
|
97
|
+
ignoredFiles:
|
|
98
|
+
- '_*'
|
|
99
|
+
- '.*'
|
|
97
100
|
|
|
98
101
|
|
|
99
102
|
####################################################
|
package/dist/cjs/bin.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const RecipleClient_1 = require("./reciple/classes/RecipleClient");
|
|
8
|
-
const RecipleConfig_1 = require("./reciple/classes/RecipleConfig");
|
|
9
|
-
const version_1 = require("./reciple/version");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
const flags_1 = require("./reciple/flags");
|
|
12
|
-
const fallout_utility_1 = require("fallout-utility");
|
|
13
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
-
require("dotenv/config");
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
|
|
17
|
-
const configPath = path_1.default.join(flags_1.cwd, './reciple.yml');
|
|
18
|
-
if ((0, fs_1.readdirSync)(flags_1.cwd).filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)(flags_1.flags.config ?? configPath)) {
|
|
19
|
-
const ask = (flags_1.flags.yes ? 'y' : null) ?? (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ') ?? '';
|
|
20
|
-
if (ask.toString().toLowerCase() !== 'y')
|
|
21
|
-
process.exit(0);
|
|
22
|
-
}
|
|
23
|
-
let configParser;
|
|
24
|
-
try {
|
|
25
|
-
configParser = new RecipleConfig_1.RecipleConfig(flags_1.flags.config ?? configPath).parseConfig();
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
console.error(`${chalk_1.default.bold.red('Config Error')}: ${chalk_1.default.white(err.message)}`);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
const config = configParser.getConfig();
|
|
32
|
-
const client = new RecipleClient_1.RecipleClient({ config: config, ...config.client });
|
|
33
|
-
if (!client.isClientLogsSilent)
|
|
34
|
-
client.logger.info('Starting Reciple client v' + version_1.rawVersion);
|
|
35
|
-
(async () => {
|
|
36
|
-
client.addCommandListeners();
|
|
37
|
-
await client.modules.startModules(await client.modules.getModulesFromFiles({
|
|
38
|
-
files: await client.modules.getModuleFiles(),
|
|
39
|
-
}));
|
|
40
|
-
client.on('ready', async () => {
|
|
41
|
-
await client.modules.loadModules(client.modules.modules.toJSON(), true);
|
|
42
|
-
if (client.config.commands.slashCommand.registerCommands)
|
|
43
|
-
await client.commands.registerApplicationCommands();
|
|
44
|
-
if (!client.isClientLogsSilent)
|
|
45
|
-
client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
|
|
46
|
-
client.on('cacheSweep', () => client.cooldowns.clean());
|
|
47
|
-
});
|
|
48
|
-
client.login(config.token).catch(err => {
|
|
49
|
-
if (!client.isClientLogsSilent)
|
|
50
|
-
client.logger.error(err);
|
|
51
|
-
});
|
|
52
|
-
})();
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
|
|
4
|
-
const builders_1 = require("../../types/builders");
|
|
5
|
-
const discord_js_1 = require("discord.js");
|
|
6
|
-
const MessageCommandOptionManager_1 = require("../managers/MessageCommandOptionManager");
|
|
7
|
-
const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
8
|
-
/**
|
|
9
|
-
* Reciple builder for message command
|
|
10
|
-
*/
|
|
11
|
-
class MessageCommandBuilder {
|
|
12
|
-
constructor(data) {
|
|
13
|
-
this.type = builders_1.CommandBuilderType.MessageCommand;
|
|
14
|
-
this.name = '';
|
|
15
|
-
this.description = '';
|
|
16
|
-
this.cooldown = 0;
|
|
17
|
-
this.aliases = [];
|
|
18
|
-
this.validateOptions = false;
|
|
19
|
-
this.options = [];
|
|
20
|
-
this.requiredBotPermissions = [];
|
|
21
|
-
this.requiredMemberPermissions = [];
|
|
22
|
-
this.allowExecuteInDM = true;
|
|
23
|
-
this.allowExecuteByBots = false;
|
|
24
|
-
this.execute = () => {
|
|
25
|
-
/* Execute */
|
|
26
|
-
};
|
|
27
|
-
if (data?.name !== undefined)
|
|
28
|
-
this.setName(data.name);
|
|
29
|
-
if (data?.description !== undefined)
|
|
30
|
-
this.setDescription(data.description);
|
|
31
|
-
if (data?.aliases !== undefined)
|
|
32
|
-
this.addAliases(data.aliases);
|
|
33
|
-
if (data?.cooldown !== undefined)
|
|
34
|
-
this.setCooldown(Number(data?.cooldown));
|
|
35
|
-
if (data?.requiredBotPermissions !== undefined)
|
|
36
|
-
this.setRequiredBotPermissions(data.requiredBotPermissions);
|
|
37
|
-
if (data?.requiredMemberPermissions !== undefined)
|
|
38
|
-
this.setRequiredMemberPermissions(data.requiredMemberPermissions);
|
|
39
|
-
if (data?.halt !== undefined)
|
|
40
|
-
this.setHalt(data.halt);
|
|
41
|
-
if (data?.execute !== undefined)
|
|
42
|
-
this.setExecute(data.execute);
|
|
43
|
-
if (data?.metadata !== undefined)
|
|
44
|
-
this.setMetadata(data.metadata);
|
|
45
|
-
if (data?.allowExecuteByBots !== undefined)
|
|
46
|
-
this.setAllowExecuteByBots(true);
|
|
47
|
-
if (data?.allowExecuteInDM !== undefined)
|
|
48
|
-
this.setAllowExecuteInDM(true);
|
|
49
|
-
if (data?.validateOptions !== undefined)
|
|
50
|
-
this.setValidateOptions(true);
|
|
51
|
-
if (data?.options !== undefined)
|
|
52
|
-
this.options = data.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o : new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder(o)));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Sets the command name
|
|
56
|
-
* @param name Command name
|
|
57
|
-
*/
|
|
58
|
-
setName(name) {
|
|
59
|
-
if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
60
|
-
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
|
|
61
|
-
this.name = name;
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Sets the command description
|
|
66
|
-
* @param description Command description
|
|
67
|
-
*/
|
|
68
|
-
setDescription(description) {
|
|
69
|
-
if (!description || typeof description !== 'string')
|
|
70
|
-
throw new TypeError('description must be a string.');
|
|
71
|
-
this.description = description;
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Add aliases to the command
|
|
76
|
-
* @param aliases Command aliases
|
|
77
|
-
*/
|
|
78
|
-
addAliases(...aliases) {
|
|
79
|
-
aliases = (0, discord_js_1.normalizeArray)(aliases);
|
|
80
|
-
if (!aliases.length)
|
|
81
|
-
throw new TypeError('Provide atleast one alias');
|
|
82
|
-
if (aliases.some(a => !a || typeof a !== 'string' || a.match(/^\s+$/)))
|
|
83
|
-
throw new TypeError('aliases must be strings and should not contain whitespaces');
|
|
84
|
-
if (this.name && aliases.some(a => a == this.name))
|
|
85
|
-
throw new TypeError('alias cannot have same name to its real command name');
|
|
86
|
-
this.aliases = [...new Set(aliases.map(s => s.toLowerCase()))];
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Set if command can be executed in dms
|
|
91
|
-
* @param allowExecuteInDM `true` if the command can execute in DMs
|
|
92
|
-
*/
|
|
93
|
-
setAllowExecuteInDM(allowExecuteInDM) {
|
|
94
|
-
if (typeof allowExecuteInDM !== 'boolean')
|
|
95
|
-
throw new TypeError('allowExecuteInDM must be a boolean.');
|
|
96
|
-
this.allowExecuteInDM = allowExecuteInDM;
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Allow command to be executed by bots
|
|
101
|
-
* @param allowExecuteByBots `true` if the command can be executed by bots
|
|
102
|
-
*/
|
|
103
|
-
setAllowExecuteByBots(allowExecuteByBots) {
|
|
104
|
-
if (typeof allowExecuteByBots !== 'boolean')
|
|
105
|
-
throw new TypeError('allowExecuteByBots must be a boolean.');
|
|
106
|
-
this.allowExecuteByBots = allowExecuteByBots;
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Add option to the command
|
|
111
|
-
* @param option Message option builder
|
|
112
|
-
*/
|
|
113
|
-
addOption(option) {
|
|
114
|
-
if (!option)
|
|
115
|
-
throw new TypeError('option must be a MessageOption.');
|
|
116
|
-
option = typeof option === 'function' ? option(new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder()) : option;
|
|
117
|
-
if (this.options.find(o => o.name === option.name))
|
|
118
|
-
throw new TypeError('option with name "' + option.name + '" already exists.');
|
|
119
|
-
if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
|
|
120
|
-
throw new TypeError('All required options must be before optional options.');
|
|
121
|
-
this.options.push(option);
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Validate options before executing
|
|
126
|
-
* @param validateOptions `true` if the command options needs to be validated before executing
|
|
127
|
-
*/
|
|
128
|
-
setValidateOptions(validateOptions) {
|
|
129
|
-
if (typeof validateOptions !== 'boolean')
|
|
130
|
-
throw new TypeError('validateOptions must be a boolean.');
|
|
131
|
-
this.validateOptions = validateOptions;
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
setCooldown(cooldown) {
|
|
135
|
-
this.cooldown = cooldown;
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
setRequiredBotPermissions(...permissions) {
|
|
139
|
-
this.requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
setRequiredMemberPermissions(...permissions) {
|
|
143
|
-
this.requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
setHalt(halt) {
|
|
147
|
-
this.halt = halt ?? undefined;
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
setExecute(execute) {
|
|
151
|
-
if (!execute || typeof execute !== 'function')
|
|
152
|
-
throw new TypeError('execute must be a function.');
|
|
153
|
-
this.execute = execute;
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
setMetadata(metadata) {
|
|
157
|
-
this.metadata = metadata;
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Returns JSON object of this builder
|
|
162
|
-
*/
|
|
163
|
-
toJSON() {
|
|
164
|
-
return {
|
|
165
|
-
type: this.type,
|
|
166
|
-
name: this.name,
|
|
167
|
-
description: this.description,
|
|
168
|
-
aliases: this.aliases,
|
|
169
|
-
cooldown: this.cooldown,
|
|
170
|
-
requiredBotPermissions: this.requiredBotPermissions,
|
|
171
|
-
requiredMemberPermissions: this.requiredMemberPermissions,
|
|
172
|
-
halt: this.halt,
|
|
173
|
-
execute: this.execute,
|
|
174
|
-
metadata: this.metadata,
|
|
175
|
-
allowExecuteByBots: this.allowExecuteByBots,
|
|
176
|
-
allowExecuteInDM: this.allowExecuteInDM,
|
|
177
|
-
validateOptions: this.validateOptions,
|
|
178
|
-
options: this.options.map(o => o.toJSON()),
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Resolve message command data/builder
|
|
183
|
-
* @param commandData Command data to resolve
|
|
184
|
-
*/
|
|
185
|
-
static resolveMessageCommand(commandData) {
|
|
186
|
-
return this.isMessageCommandBuilder(commandData) ? commandData : new MessageCommandBuilder(commandData);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Is a message command builder
|
|
190
|
-
* @param builder data to check
|
|
191
|
-
*/
|
|
192
|
-
static isMessageCommandBuilder(builder) {
|
|
193
|
-
return builder instanceof MessageCommandBuilder;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Is a message command execute data
|
|
197
|
-
* @param executeData data to check
|
|
198
|
-
*/
|
|
199
|
-
static isMessageCommandExecuteData(executeData) {
|
|
200
|
-
return executeData.builder !== undefined && this.isMessageCommandBuilder(executeData.builder);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
exports.MessageCommandBuilder = MessageCommandBuilder;
|
|
204
|
-
/**
|
|
205
|
-
* Validate message command options
|
|
206
|
-
* @param builder Command builder
|
|
207
|
-
* @param options Parsed command args
|
|
208
|
-
*/
|
|
209
|
-
async function validateMessageCommandOptions(builder, options) {
|
|
210
|
-
const args = options.args || [];
|
|
211
|
-
const required = builder.options.filter(o => o.required);
|
|
212
|
-
const optional = builder.options.filter(o => !o.required);
|
|
213
|
-
const allOptions = [...required, ...optional];
|
|
214
|
-
const result = [];
|
|
215
|
-
let i = 0;
|
|
216
|
-
for (const option of allOptions) {
|
|
217
|
-
const arg = args[i];
|
|
218
|
-
const value = {
|
|
219
|
-
name: option.name,
|
|
220
|
-
value: arg ?? undefined,
|
|
221
|
-
required: option.required,
|
|
222
|
-
invalid: false,
|
|
223
|
-
missing: false,
|
|
224
|
-
};
|
|
225
|
-
if (arg == undefined && option.required) {
|
|
226
|
-
value.missing = true;
|
|
227
|
-
result.push(value);
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
if (arg == undefined && !option.required) {
|
|
231
|
-
result.push(value);
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
const validate = option.validator ? await Promise.resolve(option.validator(arg)) : true;
|
|
235
|
-
if (!validate)
|
|
236
|
-
value.invalid = true;
|
|
237
|
-
result.push(value);
|
|
238
|
-
i++;
|
|
239
|
-
}
|
|
240
|
-
return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
|
|
241
|
-
}
|
|
242
|
-
exports.validateMessageCommandOptions = validateMessageCommandOptions;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandBuilderType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Types of command builders
|
|
6
|
-
*/
|
|
7
|
-
var CommandBuilderType;
|
|
8
|
-
(function (CommandBuilderType) {
|
|
9
|
-
CommandBuilderType[CommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
|
|
10
|
-
CommandBuilderType[CommandBuilderType["SlashCommand"] = 1] = "SlashCommand";
|
|
11
|
-
})(CommandBuilderType = exports.CommandBuilderType || (exports.CommandBuilderType = {}));
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ApplicationCommandData, Collection, GuildResolvable, RestOrArray } from 'discord.js';
|
|
2
|
-
import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandBuilderType, MessageCommandData, SlashCommandData } from '../../types/builders';
|
|
3
|
-
import { MessageCommandBuilder } from '../builders/MessageCommandBuilder';
|
|
4
|
-
import { SlashCommandBuilder } from '../builders/SlashCommandBuilder';
|
|
5
|
-
import { RecipleClient } from '../RecipleClient';
|
|
6
|
-
import { ApplicationCommandBuilder } from './ApplicationCommandManager';
|
|
7
|
-
export interface ClientCommandManagerOptions {
|
|
8
|
-
client: RecipleClient;
|
|
9
|
-
messageCommands?: (MessageCommandBuilder | MessageCommandData)[];
|
|
10
|
-
slashCommands?: (AnySlashCommandBuilder | SlashCommandData)[];
|
|
11
|
-
}
|
|
12
|
-
export declare class ClientCommandManager {
|
|
13
|
-
readonly client: RecipleClient;
|
|
14
|
-
readonly slashCommands: Collection<string, AnySlashCommandBuilder>;
|
|
15
|
-
readonly messageCommands: Collection<string, MessageCommandBuilder>;
|
|
16
|
-
readonly additionalApplicationCommands: (ApplicationCommandBuilder | ApplicationCommandData)[];
|
|
17
|
-
get applicationCommandsSize(): number;
|
|
18
|
-
constructor(options: ClientCommandManagerOptions);
|
|
19
|
-
/**
|
|
20
|
-
* Add command to command manager
|
|
21
|
-
* @param commands Any command data or builder
|
|
22
|
-
*/
|
|
23
|
-
add(...commands: RestOrArray<AnyCommandBuilder | AnyCommandData>): this;
|
|
24
|
-
/**
|
|
25
|
-
* Get command builder by name or alias if it's a message command
|
|
26
|
-
* @param command Command name
|
|
27
|
-
* @param type Command type
|
|
28
|
-
*/
|
|
29
|
-
get(command: string, type?: undefined): AnyCommandBuilder | undefined;
|
|
30
|
-
get(command: string, type?: CommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
|
|
31
|
-
get(command: string, type?: CommandBuilderType.SlashCommand): SlashCommandBuilder | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Register application commands
|
|
34
|
-
* @param guilds Register application commands to guilds
|
|
35
|
-
*/
|
|
36
|
-
registerApplicationCommands(...guilds: RestOrArray<GuildResolvable>): Promise<this>;
|
|
37
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Collection, RestOrArray } from 'discord.js';
|
|
2
|
-
import { ClientModuleManagerGetModulesFromFilesOptions } from '../../types/paramOptions';
|
|
3
|
-
import { RecipleClient } from '../RecipleClient';
|
|
4
|
-
import { RecipleModule, RecipleScript } from '../RecipleModule';
|
|
5
|
-
export interface ClientModuleManagerOptions {
|
|
6
|
-
client: RecipleClient;
|
|
7
|
-
modules?: (RecipleModule | RecipleScript)[];
|
|
8
|
-
}
|
|
9
|
-
export declare class ClientModuleManager {
|
|
10
|
-
readonly client: RecipleClient;
|
|
11
|
-
readonly modules: Collection<string, RecipleModule>;
|
|
12
|
-
constructor(options: ClientModuleManagerOptions);
|
|
13
|
-
startModules(modules: RecipleModule[], ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
14
|
-
loadModules(modules: RecipleModule[], addModuleCommandsToClient?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
15
|
-
unLoadModules(modules: RecipleModule[], removeUnloadedModules?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
16
|
-
getModulesFromFiles(options: ClientModuleManagerGetModulesFromFilesOptions): Promise<RecipleModule[]>;
|
|
17
|
-
static validateScript(script: unknown): script is RecipleScript;
|
|
18
|
-
getModuleFiles(...folders: RestOrArray<string>): Promise<string[]>;
|
|
19
|
-
}
|
package/docs/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# [VIEW DOCS](https://reciple.js.org/#/docs)
|