reciple 1.0.2 → 1.0.3
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 +4 -1
- package/bin/reciple/classes/Client.js +2 -2
- package/bin/reciple/classes/Config.d.ts +2 -0
- package/bin/reciple/classes/Config.js +9 -1
- package/bin/reciple/commandPermissions.d.ts +1 -1
- package/bin/reciple/commandPermissions.js +4 -4
- package/bin/reciple/flags.d.ts +1 -0
- package/bin/reciple/flags.js +3 -3
- package/bin/reciple/modules.d.ts +2 -2
- package/package.json +1 -1
- package/resource/reciple.yml +3 -1
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
95
95
|
builder: command,
|
|
96
96
|
client: this
|
|
97
97
|
};
|
|
98
|
-
yield Promise.resolve(command.execute(options));
|
|
98
|
+
yield Promise.resolve(command.execute(options)).catch(err => { this.logger.error(`An error occured executing "${command.name}"`); this.logger.error(err); });
|
|
99
99
|
this.emit('recipleMessageCommandCreate', options);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -117,7 +117,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
117
117
|
builder: command,
|
|
118
118
|
client: this
|
|
119
119
|
};
|
|
120
|
-
yield Promise.resolve(command.execute(options));
|
|
120
|
+
yield Promise.resolve(command.execute(options)).catch(err => { this.logger.error(`An error occured executing "${command.name}"`); this.logger.error(err); });
|
|
121
121
|
this.emit('recipleInteractionCommandCreate', options);
|
|
122
122
|
}
|
|
123
123
|
return this;
|
|
@@ -43,6 +43,7 @@ export interface Config {
|
|
|
43
43
|
[key: string]: MessageOptions | string;
|
|
44
44
|
};
|
|
45
45
|
modulesFolder: string;
|
|
46
|
+
version?: string;
|
|
46
47
|
}
|
|
47
48
|
export declare class RecipleConfig {
|
|
48
49
|
config?: Config;
|
|
@@ -51,5 +52,6 @@ export declare class RecipleConfig {
|
|
|
51
52
|
parseConfig(): RecipleConfig;
|
|
52
53
|
getConfig(): Config;
|
|
53
54
|
parseToken(askIfNull?: boolean): string | null;
|
|
55
|
+
private isSupportedConfig;
|
|
54
56
|
private askToken;
|
|
55
57
|
}
|
|
@@ -9,6 +9,7 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const flags_1 = require("../flags");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const yaml_1 = __importDefault(require("yaml"));
|
|
12
|
+
const version_1 = require("../version");
|
|
12
13
|
class RecipleConfig {
|
|
13
14
|
constructor(configPath) {
|
|
14
15
|
this.configPath = './reciple.yml';
|
|
@@ -17,11 +18,12 @@ class RecipleConfig {
|
|
|
17
18
|
this.configPath = configPath;
|
|
18
19
|
}
|
|
19
20
|
parseConfig() {
|
|
21
|
+
var _a;
|
|
20
22
|
if (!(0, fs_1.existsSync)(this.configPath)) {
|
|
21
23
|
const defaultConfigPath = path_1.default.join(__dirname, '../../../resource/reciple.yml');
|
|
22
24
|
if (!(0, fs_1.existsSync)(defaultConfigPath))
|
|
23
25
|
throw new Error('Default Config file not found. Please reinstall Reciple.');
|
|
24
|
-
const defaultConfig = (0, fs_1.readFileSync)(defaultConfigPath, 'utf-8');
|
|
26
|
+
const defaultConfig = (0, fallout_utility_1.replaceAll)((0, fs_1.readFileSync)(defaultConfigPath, 'utf-8'), 'VERSION', version_1.version);
|
|
25
27
|
(0, fs_1.writeFileSync)(this.configPath, defaultConfig, 'utf-8');
|
|
26
28
|
if (!(0, fs_1.existsSync)(this.configPath))
|
|
27
29
|
throw new Error('Failed to create config file.');
|
|
@@ -36,6 +38,8 @@ class RecipleConfig {
|
|
|
36
38
|
throw new Error('Failed to read config file.');
|
|
37
39
|
const config = (0, fs_1.readFileSync)(this.configPath, 'utf-8');
|
|
38
40
|
this.config = yaml_1.default.parse(config);
|
|
41
|
+
if (!this.isSupportedConfig())
|
|
42
|
+
throw new Error('Unsupported config version. Your config version: ' + (((_a = this.config) === null || _a === void 0 ? void 0 : _a.version) || 'No version specified.') + ', Reciple version: ' + version_1.version);
|
|
39
43
|
return this;
|
|
40
44
|
}
|
|
41
45
|
getConfig() {
|
|
@@ -61,6 +65,10 @@ class RecipleConfig {
|
|
|
61
65
|
}
|
|
62
66
|
return token || (askIfNull ? this.askToken() : null);
|
|
63
67
|
}
|
|
68
|
+
isSupportedConfig() {
|
|
69
|
+
var _a;
|
|
70
|
+
return (((_a = this.config) === null || _a === void 0 ? void 0 : _a.version) && this.config.version != version_1.version) ? false : true;
|
|
71
|
+
}
|
|
64
72
|
askToken() {
|
|
65
73
|
return flags_1.token || (0, fallout_utility_1.input)({ 'text': 'Bot Token >>> ', echo: '*', repeatIfEmpty: true, exitStrings: ['exit', 'quit', ''], sigint: true }) || null;
|
|
66
74
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Permissions } from "discord.js";
|
|
2
2
|
import { Config } from "./classes/Config";
|
|
3
|
-
export declare function commandPermissions(commandName: string,
|
|
3
|
+
export declare function commandPermissions(commandName: string, memberPermissions: Permissions | null, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands']): boolean;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.commandPermissions = void 0;
|
|
4
|
-
function commandPermissions(commandName,
|
|
5
|
-
if (!(
|
|
4
|
+
function commandPermissions(commandName, memberPermissions, configConmmandPermissions) {
|
|
5
|
+
if (!(configConmmandPermissions === null || configConmmandPermissions === void 0 ? void 0 : configConmmandPermissions.enabled))
|
|
6
6
|
return true;
|
|
7
|
-
const command =
|
|
7
|
+
const command = configConmmandPermissions.commands.find(c => c.command.toLowerCase() === commandName.toLowerCase());
|
|
8
8
|
if (!command)
|
|
9
9
|
return true;
|
|
10
10
|
if (!command.permissions.length)
|
|
11
11
|
return true;
|
|
12
|
-
return
|
|
12
|
+
return memberPermissions ? memberPermissions.has(command.permissions) : false;
|
|
13
13
|
}
|
|
14
14
|
exports.commandPermissions = commandPermissions;
|
package/bin/reciple/flags.d.ts
CHANGED
package/bin/reciple/flags.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.token = void 0;
|
|
3
|
+
exports.token = exports.flags = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
|
-
|
|
5
|
+
exports.flags = commander_1.program
|
|
6
6
|
.option('-t, --token <token>', 'Replace used bot token')
|
|
7
7
|
.parse().opts();
|
|
8
|
-
exports.token = flags.token;
|
|
8
|
+
exports.token = exports.flags.token;
|
package/bin/reciple/modules.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare type loadedModules = {
|
|
|
9
9
|
export interface RecipleScript {
|
|
10
10
|
versions: string | string[];
|
|
11
11
|
commands?: (MessageCommandBuilder | InteractionCommandBuilder)[];
|
|
12
|
-
onLoad?: (reciple: RecipleClient) => void
|
|
13
|
-
onStart: (reciple: RecipleClient) => boolean
|
|
12
|
+
onLoad?: (reciple: RecipleClient) => void | Promise<void>;
|
|
13
|
+
onStart: (reciple: RecipleClient) => boolean | Promise<boolean>;
|
|
14
14
|
}
|
|
15
15
|
export interface RecipleModule {
|
|
16
16
|
script: RecipleScript;
|
package/package.json
CHANGED