reciple 1.2.0 → 1.3.2
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/bin/reciple/classes/Client.d.ts +2 -2
- package/bin/reciple/classes/Client.js +3 -8
- package/bin/reciple/classes/Config.d.ts +1 -0
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +2 -2
- package/bin/reciple/classes/builders/InteractionCommandBuilder.js +1 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +3 -12
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +14 -46
- package/bin/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +10 -0
- package/bin/reciple/classes/builders/MessageCommandOptionBuilder.js +36 -0
- package/bin/reciple/modules.d.ts +2 -2
- package/bin/reciple/modules.js +6 -3
- package/bin/reciple/registerInteractionCommands.js +12 -13
- package/bin/reciple/version.d.ts +1 -1
- package/bin/reciple/version.js +11 -20
- package/package.json +9 -10
- package/resource/reciple.yml +4 -0
- package/CHANGELOG.md +0 -28
|
@@ -10,10 +10,10 @@ export interface RecipleClientOptions extends ClientOptions {
|
|
|
10
10
|
}
|
|
11
11
|
export interface RecipleClientCommands {
|
|
12
12
|
MESSAGE_COMMANDS: {
|
|
13
|
-
[
|
|
13
|
+
[commandName: string]: MessageCommandBuilder;
|
|
14
14
|
};
|
|
15
15
|
INTERACTION_COMMANDS: {
|
|
16
|
-
[
|
|
16
|
+
[commandName: string]: InteractionCommandBuilder;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export interface RecipleClientEvents extends ClientEvents {
|
|
@@ -90,7 +90,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
90
90
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, ((_b = this.config) === null || _b === void 0 ? void 0 : _b.prefix) || '!', ((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.messageCommand.commandArgumentSeparator) || ' ');
|
|
91
91
|
if (!(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command) || !parseCommand)
|
|
92
92
|
return this;
|
|
93
|
-
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command];
|
|
93
|
+
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command.toLowerCase()];
|
|
94
94
|
if (!command)
|
|
95
95
|
return this;
|
|
96
96
|
if ((0, commandPermissions_1.commandPermissions)(command.name, (_d = message.member) === null || _d === void 0 ? void 0 : _d.permissions, (_e = this.config) === null || _e === void 0 ? void 0 : _e.permissions.messageCommands, command)) {
|
|
@@ -144,7 +144,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
_commandExecuteError(err, command) {
|
|
147
|
-
var _a, _b, _c, _d
|
|
147
|
+
var _a, _b, _c, _d;
|
|
148
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
149
|
this.logger.error(`An error occured executing ${command.builder.builder == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
|
|
150
150
|
this.logger.error(err);
|
|
@@ -158,12 +158,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
158
158
|
else if (command === null || command === void 0 ? void 0 : command.interaction) {
|
|
159
159
|
if (!((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.interactionCommand.replyOnError))
|
|
160
160
|
return;
|
|
161
|
-
|
|
162
|
-
yield command.interaction.reply(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
yield command.interaction.followUp(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
|
|
166
|
-
}
|
|
161
|
+
yield command.interaction.followUp(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
|
|
167
162
|
}
|
|
168
163
|
});
|
|
169
164
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
2
|
-
import { CommandInteraction, PermissionFlags } from 'discord.js';
|
|
2
|
+
import { CommandInteraction, PermissionFlags, PermissionString } from 'discord.js';
|
|
3
3
|
import { RecipleClient } from '../Client';
|
|
4
4
|
export interface RecipleInteractionCommandExecute {
|
|
5
5
|
interaction: CommandInteraction;
|
|
@@ -9,7 +9,7 @@ export interface RecipleInteractionCommandExecute {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
11
11
|
readonly builder: string;
|
|
12
|
-
requiredPermissions: (
|
|
12
|
+
requiredPermissions: (PermissionFlags | PermissionString)[];
|
|
13
13
|
allowExecuteInDM: boolean;
|
|
14
14
|
execute: (options: RecipleInteractionCommandExecute) => void;
|
|
15
15
|
setRequiredPermissions(requiredPermissions: (keyof PermissionFlags)[]): InteractionCommandBuilder;
|
|
@@ -8,7 +8,7 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
|
|
|
8
8
|
this.builder = 'INTERACTION_COMMAND';
|
|
9
9
|
this.requiredPermissions = [];
|
|
10
10
|
this.allowExecuteInDM = true;
|
|
11
|
-
this.execute = (
|
|
11
|
+
this.execute = () => { };
|
|
12
12
|
}
|
|
13
13
|
setRequiredPermissions(requiredPermissions) {
|
|
14
14
|
if (!requiredPermissions || !Array.isArray(requiredPermissions))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Message, PermissionFlags, PermissionString } from 'discord.js';
|
|
2
2
|
import { Command } from 'fallout-utility';
|
|
3
3
|
import { RecipleClient } from '../Client';
|
|
4
|
+
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
4
5
|
export declare type CommandMessage = Command;
|
|
5
6
|
export interface RecipleMessageCommandExecute {
|
|
6
7
|
message: Message;
|
|
@@ -13,21 +14,11 @@ export interface MessageCommandValidatedOption {
|
|
|
13
14
|
value: string;
|
|
14
15
|
required: boolean;
|
|
15
16
|
}
|
|
16
|
-
export declare class MessageOption {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
required: boolean;
|
|
20
|
-
validate: (value: string) => boolean;
|
|
21
|
-
setName(name: string): MessageOption;
|
|
22
|
-
setDescription(description: string): MessageOption;
|
|
23
|
-
setRequired(required: boolean): MessageOption;
|
|
24
|
-
setValidator(validator: (value: string) => boolean): MessageOption;
|
|
25
|
-
}
|
|
26
17
|
export declare class MessageCommandBuilder {
|
|
27
18
|
readonly builder: string;
|
|
28
19
|
name: string;
|
|
29
20
|
description: string;
|
|
30
|
-
options:
|
|
21
|
+
options: MessageCommandOptionBuilder[];
|
|
31
22
|
validateOptions: boolean;
|
|
32
23
|
requiredPermissions: (PermissionFlags | PermissionString)[];
|
|
33
24
|
allowExecuteInDM: boolean;
|
|
@@ -39,7 +30,7 @@ export declare class MessageCommandBuilder {
|
|
|
39
30
|
setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
|
|
40
31
|
setDescription(description: string): MessageCommandBuilder;
|
|
41
32
|
setExecute(execute: (options: RecipleMessageCommandExecute) => void): MessageCommandBuilder;
|
|
42
|
-
addOption(option:
|
|
33
|
+
addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
|
|
43
34
|
setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
|
|
44
35
|
getCommandOptionValues(options: CommandMessage): undefined | MessageCommandValidatedOption[];
|
|
45
36
|
}
|
|
@@ -1,39 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageCommandBuilder =
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
this.name = '';
|
|
7
|
-
this.description = '';
|
|
8
|
-
this.required = true;
|
|
9
|
-
this.validate = () => true;
|
|
10
|
-
}
|
|
11
|
-
setName(name) {
|
|
12
|
-
if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
13
|
-
throw new Error('name must be a string and match the regex /^[\\w-]{1,32}$/.');
|
|
14
|
-
this.name = name;
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
setDescription(description) {
|
|
18
|
-
if (!description || typeof description !== 'string')
|
|
19
|
-
throw new Error('description must be a string.');
|
|
20
|
-
this.description = description;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
setRequired(required) {
|
|
24
|
-
if (typeof required !== 'boolean')
|
|
25
|
-
throw new Error('required must be a boolean.');
|
|
26
|
-
this.required = required;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
setValidator(validator) {
|
|
30
|
-
if (!validator || typeof validator !== 'function')
|
|
31
|
-
throw new Error('validator must be a function.');
|
|
32
|
-
this.validate = validator;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.MessageOption = MessageOption;
|
|
3
|
+
exports.MessageCommandBuilder = void 0;
|
|
4
|
+
const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
37
5
|
class MessageCommandBuilder {
|
|
38
6
|
constructor() {
|
|
39
7
|
this.builder = 'MESSAGE_COMMAND';
|
|
@@ -44,58 +12,58 @@ class MessageCommandBuilder {
|
|
|
44
12
|
this.requiredPermissions = [];
|
|
45
13
|
this.allowExecuteInDM = true;
|
|
46
14
|
this.allowExecuteByBots = false;
|
|
47
|
-
this.execute = (
|
|
15
|
+
this.execute = () => { };
|
|
48
16
|
}
|
|
49
17
|
setName(name) {
|
|
50
18
|
if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
51
|
-
throw new
|
|
19
|
+
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
|
|
52
20
|
this.name = name;
|
|
53
21
|
return this;
|
|
54
22
|
}
|
|
55
23
|
setRequiredPermissions(permissions) {
|
|
56
24
|
if (!permissions || !Array.isArray(permissions))
|
|
57
|
-
throw new
|
|
25
|
+
throw new TypeError('permissions must be an array.');
|
|
58
26
|
this.requiredPermissions = permissions;
|
|
59
27
|
return this;
|
|
60
28
|
}
|
|
61
29
|
setAllowExecuteInDM(allowExecuteInDM) {
|
|
62
30
|
if (typeof allowExecuteInDM !== 'boolean')
|
|
63
|
-
throw new
|
|
31
|
+
throw new TypeError('allowExecuteInDM must be a boolean.');
|
|
64
32
|
this.allowExecuteInDM = allowExecuteInDM;
|
|
65
33
|
return this;
|
|
66
34
|
}
|
|
67
35
|
setAllowExecuteByBots(allowExecuteByBots) {
|
|
68
36
|
if (typeof allowExecuteByBots !== 'boolean')
|
|
69
|
-
throw new
|
|
37
|
+
throw new TypeError('allowExecuteByBots must be a boolean.');
|
|
70
38
|
this.allowExecuteByBots = allowExecuteByBots;
|
|
71
39
|
return this;
|
|
72
40
|
}
|
|
73
41
|
setDescription(description) {
|
|
74
42
|
if (!description || typeof description !== 'string')
|
|
75
|
-
throw new
|
|
43
|
+
throw new TypeError('description must be a string.');
|
|
76
44
|
this.description = description;
|
|
77
45
|
return this;
|
|
78
46
|
}
|
|
79
47
|
setExecute(execute) {
|
|
80
48
|
if (!execute || typeof execute !== 'function')
|
|
81
|
-
throw new
|
|
49
|
+
throw new TypeError('execute must be a function.');
|
|
82
50
|
this.execute = execute;
|
|
83
51
|
return this;
|
|
84
52
|
}
|
|
85
53
|
addOption(option) {
|
|
86
54
|
if (!option)
|
|
87
|
-
throw new
|
|
88
|
-
option = typeof option === 'function' ? option(new
|
|
55
|
+
throw new TypeError('option must be a MessageOption.');
|
|
56
|
+
option = typeof option === 'function' ? option(new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder()) : option;
|
|
89
57
|
if (this.options.find(o => o.name === option.name))
|
|
90
|
-
throw new
|
|
58
|
+
throw new TypeError('option with name "' + option.name + '" already exists.');
|
|
91
59
|
if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
|
|
92
|
-
throw new
|
|
60
|
+
throw new TypeError('All required options must be before optional options.');
|
|
93
61
|
this.options = [...this.options, option];
|
|
94
62
|
return this;
|
|
95
63
|
}
|
|
96
64
|
setValidateOptions(validateOptions) {
|
|
97
65
|
if (typeof validateOptions !== 'boolean')
|
|
98
|
-
throw new
|
|
66
|
+
throw new TypeError('validateOptions must be a boolean.');
|
|
99
67
|
this.validateOptions = validateOptions;
|
|
100
68
|
return this;
|
|
101
69
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class MessageCommandOptionBuilder {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
required: boolean;
|
|
5
|
+
validate: (value: string) => boolean;
|
|
6
|
+
setName(name: string): MessageCommandOptionBuilder;
|
|
7
|
+
setDescription(description: string): MessageCommandOptionBuilder;
|
|
8
|
+
setRequired(required: boolean): MessageCommandOptionBuilder;
|
|
9
|
+
setValidator(validator: (value: string) => boolean): MessageCommandOptionBuilder;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageCommandOptionBuilder = void 0;
|
|
4
|
+
class MessageCommandOptionBuilder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = '';
|
|
7
|
+
this.description = '';
|
|
8
|
+
this.required = true;
|
|
9
|
+
this.validate = () => true;
|
|
10
|
+
}
|
|
11
|
+
setName(name) {
|
|
12
|
+
if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
13
|
+
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/.');
|
|
14
|
+
this.name = name;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
setDescription(description) {
|
|
18
|
+
if (!description || typeof description !== 'string')
|
|
19
|
+
throw new TypeError('description must be a string.');
|
|
20
|
+
this.description = description;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
setRequired(required) {
|
|
24
|
+
if (typeof required !== 'boolean')
|
|
25
|
+
throw new TypeError('required must be a boolean.');
|
|
26
|
+
this.required = required;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
setValidator(validator) {
|
|
30
|
+
if (!validator || typeof validator !== 'function')
|
|
31
|
+
throw new TypeError('validator must be a function.');
|
|
32
|
+
this.validate = validator;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.MessageCommandOptionBuilder = MessageCommandOptionBuilder;
|
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
|
|
13
|
-
onStart
|
|
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/bin/reciple/modules.js
CHANGED
|
@@ -17,14 +17,17 @@ const fs_1 = require("fs");
|
|
|
17
17
|
const version_1 = require("./version");
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
function loadModules(client) {
|
|
20
|
-
var _a, _b;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
const response = { commands: [], modules: [] };
|
|
23
23
|
const modulesDir = ((_a = client.config) === null || _a === void 0 ? void 0 : _a.modulesFolder) || './modules';
|
|
24
24
|
const logger = client.logger;
|
|
25
25
|
if (!(0, fs_1.existsSync)(modulesDir))
|
|
26
26
|
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
27
|
-
const
|
|
27
|
+
const ignoredFiles = (((_b = client.config) === null || _b === void 0 ? void 0 : _b.ignoredFiles) || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
|
|
28
|
+
const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => {
|
|
29
|
+
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.includes(file);
|
|
30
|
+
});
|
|
28
31
|
for (const script of scripts) {
|
|
29
32
|
const modulePath = path_1.default.resolve(modulesDir, script);
|
|
30
33
|
const commands = [];
|
|
@@ -32,7 +35,7 @@ function loadModules(client) {
|
|
|
32
35
|
try {
|
|
33
36
|
const reqMod = require(modulePath);
|
|
34
37
|
module_ = !!(reqMod === null || reqMod === void 0 ? void 0 : reqMod.default) ? reqMod.default : reqMod;
|
|
35
|
-
if (!((
|
|
38
|
+
if (!((_c = module_.versions) === null || _c === void 0 ? void 0 : _c.length))
|
|
36
39
|
throw new Error('Module does not have supported versions.');
|
|
37
40
|
const versions = typeof module_.versions === 'object' ? module_.versions : [module_.versions];
|
|
38
41
|
if (!versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
|
|
@@ -15,20 +15,19 @@ function registerInteractionCommands(client, cmds, overwriteGuilds) {
|
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
-
if (typeof c.toJSON
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
cmd.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return c.toJSON();
|
|
18
|
+
if (typeof c.toJSON == 'undefined')
|
|
19
|
+
return c;
|
|
20
|
+
const cmd = c;
|
|
21
|
+
if ((cmd === null || cmd === void 0 ? void 0 : cmd.builder) === 'INTERACTION_COMMAND' && ((_a = client.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.setRequiredPermissions)) {
|
|
22
|
+
const permissions = (_g = (((_c = (_b = client.config) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.interactionCommands.enabled) ?
|
|
23
|
+
(_f = (_e = (_d = client.config) === null || _d === void 0 ? void 0 : _d.permissions) === null || _e === void 0 ? void 0 : _e.interactionCommands.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _f === void 0 ? void 0 : _f.permissions :
|
|
24
|
+
undefined)) !== null && _g !== void 0 ? _g : cmd.requiredPermissions;
|
|
25
|
+
cmd.setRequiredPermissions(permissions);
|
|
26
|
+
client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
|
|
27
|
+
client.logger.debug(`Set required permissions for ${cmd.name} to ${permissions.join(', ')}`);
|
|
28
|
+
return cmd.toJSON();
|
|
30
29
|
}
|
|
31
|
-
return c;
|
|
30
|
+
return c.toJSON();
|
|
32
31
|
})) !== null && _a !== void 0 ? _a : [];
|
|
33
32
|
if (!commands || !commands.length) {
|
|
34
33
|
client.logger.warn('No interaction commands found.');
|
package/bin/reciple/version.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare function parseVersion(ver: string): {
|
|
|
5
5
|
minor: number;
|
|
6
6
|
patch: number;
|
|
7
7
|
};
|
|
8
|
-
export declare function isSupportedVersion(
|
|
8
|
+
export declare function isSupportedVersion(versionRange: string, supportedVersion?: string): boolean;
|
package/bin/reciple/version.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isSupportedVersion = exports.parseVersion = exports.validVersion = exports.version = void 0;
|
|
4
|
-
const
|
|
7
|
+
const semver_1 = __importDefault(require("semver"));
|
|
5
8
|
exports.version = require('../../package.json').version;
|
|
6
9
|
function validVersion(ver) {
|
|
7
|
-
|
|
8
|
-
return false;
|
|
9
|
-
const [major, minor, patch] = ver.split('.');
|
|
10
|
-
if (!(0, fallout_utility_1.isNumber)(major) || !(0, fallout_utility_1.isNumber)(minor) || !(0, fallout_utility_1.isNumber)(patch))
|
|
11
|
-
return false;
|
|
12
|
-
return true;
|
|
10
|
+
return semver_1.default.valid(semver_1.default.coerce(ver)) !== null;
|
|
13
11
|
}
|
|
14
12
|
exports.validVersion = validVersion;
|
|
15
13
|
function parseVersion(ver) {
|
|
14
|
+
var _a, _b;
|
|
16
15
|
if (!validVersion(ver))
|
|
17
16
|
throw new TypeError(`Invalid version: ${ver}`);
|
|
18
|
-
const [major, minor, patch] = ver.split('.');
|
|
17
|
+
const [major, minor, patch] = (_b = (_a = `${semver_1.default.coerce(ver)}`) === null || _a === void 0 ? void 0 : _a.split('.')) !== null && _b !== void 0 ? _b : [];
|
|
19
18
|
return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
|
|
20
19
|
}
|
|
21
20
|
exports.parseVersion = parseVersion;
|
|
22
|
-
function isSupportedVersion(
|
|
21
|
+
function isSupportedVersion(versionRange, supportedVersion) {
|
|
23
22
|
supportedVersion = supportedVersion || exports.version;
|
|
24
|
-
if (!validVersion(
|
|
25
|
-
throw new TypeError(`Invalid version: ${
|
|
23
|
+
if (!validVersion(versionRange))
|
|
24
|
+
throw new TypeError(`Invalid version: ${versionRange}`);
|
|
26
25
|
if (!validVersion(supportedVersion))
|
|
27
26
|
throw new TypeError(`Invalid supported version: ${supportedVersion}`);
|
|
28
|
-
|
|
29
|
-
const { major: supportedMajor, minor: supportedMinor, patch: supportedPatch } = parseVersion(supportedVersion);
|
|
30
|
-
if (major !== supportedMajor)
|
|
31
|
-
return false;
|
|
32
|
-
if (minor !== supportedMinor)
|
|
33
|
-
return false;
|
|
34
|
-
if (patch > supportedPatch)
|
|
35
|
-
return false;
|
|
36
|
-
return true;
|
|
27
|
+
return semver_1.default.satisfies(supportedVersion, versionRange);
|
|
37
28
|
}
|
|
38
29
|
exports.isSupportedVersion = isSupportedVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "A Discord.js bot",
|
|
5
5
|
"author": "FalloutStudios",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -13,28 +13,27 @@
|
|
|
13
13
|
"resource",
|
|
14
14
|
"package.json",
|
|
15
15
|
"LICENSE",
|
|
16
|
-
"README.md"
|
|
17
|
-
"CHANGELOG.md"
|
|
16
|
+
"README.md"
|
|
18
17
|
],
|
|
19
18
|
"scripts": {
|
|
20
19
|
"clean": "rimraf bin",
|
|
21
20
|
"compile": "yarn clean && tsc",
|
|
22
21
|
"build": "yarn compile && npm un reciple -g && npm i ./ -g",
|
|
23
22
|
"build:publish": "yarn run build && yarn run changelog && yarn publish",
|
|
24
|
-
"changelog": "changelog generate",
|
|
25
23
|
"test": "cd test && reciple",
|
|
26
|
-
"test:
|
|
24
|
+
"test:build": "yarn run build && yarn test:run"
|
|
27
25
|
},
|
|
28
26
|
"dependencies": {
|
|
29
|
-
"commander": "^9.
|
|
27
|
+
"commander": "^9.3.0",
|
|
30
28
|
"discord.js": "^13.7.0",
|
|
31
29
|
"dotenv": "^16.0.1",
|
|
32
30
|
"fallout-utility": "^1.3.14",
|
|
33
|
-
"
|
|
31
|
+
"semver": "^7.3.7",
|
|
32
|
+
"yaml": "^2.1.1"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^17.0.
|
|
37
|
-
"
|
|
38
|
-
"typescript": "^4.
|
|
35
|
+
"@types/node": "^17.0.40",
|
|
36
|
+
"@types/semver": "^7.3.9",
|
|
37
|
+
"typescript": "^4.7.3"
|
|
39
38
|
}
|
|
40
39
|
}
|
package/resource/reciple.yml
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#### 1.2.0 (2022-05-21)
|
|
2
|
-
|
|
3
|
-
##### New Features
|
|
4
|
-
|
|
5
|
-
* **permissions:** you can now set required permissions for interaction command (3a80154f)
|
|
6
|
-
|
|
7
|
-
##### Refactors
|
|
8
|
-
|
|
9
|
-
* **permissions:** some changes to message command required permissions (22a01ae3)
|
|
10
|
-
|
|
11
|
-
#### 1.2.0 (2022-05-21)
|
|
12
|
-
|
|
13
|
-
##### New Features
|
|
14
|
-
|
|
15
|
-
* **permissions:** you can now set required permissions for interaction command (3a80154f)
|
|
16
|
-
|
|
17
|
-
##### Refactors
|
|
18
|
-
|
|
19
|
-
* **permissions:** some changes to message command required permissions (22a01ae3)
|
|
20
|
-
|
|
21
|
-
#### 1.1.6 (2022-05-21)
|
|
22
|
-
|
|
23
|
-
##### Bug Fixes
|
|
24
|
-
|
|
25
|
-
* **interactionCommands:** Interaction commands error (55a29d74)
|
|
26
|
-
|
|
27
|
-
#### 1.1.5 (2022-05-21)
|
|
28
|
-
|