reciple 5.4.1-pre.5 → 5.4.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/bin/{types/bin.d.ts → bin.d.ts} +0 -0
- package/bin/{cjs/bin.js → bin.js} +11 -22
- package/bin/{types/index.d.ts → index.d.ts} +0 -0
- package/bin/{cjs/index.js → index.js} +0 -0
- package/bin/{types/reciple → reciple}/classes/CommandCooldownManager.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/classes/CommandCooldownManager.js +12 -8
- package/bin/{types/reciple → reciple}/classes/MessageCommandOptionManager.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/classes/MessageCommandOptionManager.js +4 -5
- package/bin/{types/reciple → reciple}/classes/RecipleClient.d.ts +4 -4
- package/bin/{mjs/reciple → reciple}/classes/RecipleClient.js +68 -61
- package/bin/{types/reciple → reciple}/classes/RecipleConfig.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/classes/RecipleConfig.js +6 -9
- package/bin/{types/reciple → reciple}/classes/builders/MessageCommandBuilder.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/classes/builders/MessageCommandBuilder.js +22 -17
- package/bin/{types/reciple → reciple}/classes/builders/MessageCommandOptionBuilder.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/classes/builders/MessageCommandOptionBuilder.js +5 -1
- package/bin/{types/reciple → reciple}/classes/builders/SlashCommandBuilder.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/classes/builders/SlashCommandBuilder.js +29 -29
- package/bin/{types/reciple → reciple}/flags.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/flags.js +0 -0
- package/bin/{types/reciple → reciple}/logger.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/logger.js +1 -2
- package/bin/{types/reciple → reciple}/modules.d.ts +0 -0
- package/bin/reciple/modules.js +113 -0
- package/bin/{types/reciple → reciple}/permissions.d.ts +6 -2
- package/bin/reciple/permissions.js +34 -0
- package/bin/{types/reciple → reciple}/registerApplicationCommands.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/registerApplicationCommands.js +9 -5
- package/bin/{types/reciple → reciple}/types/builders.d.ts +1 -1
- package/bin/{cjs/reciple → reciple}/types/builders.js +0 -0
- package/bin/{types/reciple → reciple}/types/commands.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/types/commands.js +0 -0
- package/bin/{types/reciple → reciple}/types/paramOptions.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/types/paramOptions.js +0 -0
- package/bin/{types/reciple → reciple}/util.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/util.js +0 -0
- package/bin/{types/reciple → reciple}/version.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/version.js +0 -0
- package/package.json +10 -14
- package/bin/cjs/package.json +0 -3
- package/bin/cjs/reciple/classes/CommandCooldownManager.js +0 -92
- package/bin/cjs/reciple/classes/RecipleClient.js +0 -400
- package/bin/cjs/reciple/classes/builders/MessageCommandBuilder.js +0 -233
- package/bin/cjs/reciple/classes/builders/MessageCommandOptionBuilder.js +0 -71
- package/bin/cjs/reciple/modules.js +0 -100
- package/bin/cjs/reciple/permissions.js +0 -28
- package/bin/cjs/reciple/registerApplicationCommands.js +0 -64
- package/bin/mjs/bin.js +0 -46
- package/bin/mjs/index.js +0 -17
- package/bin/mjs/package.json +0 -3
- package/bin/mjs/reciple/classes/MessageCommandOptionManager.js +0 -21
- package/bin/mjs/reciple/classes/RecipleConfig.js +0 -92
- package/bin/mjs/reciple/classes/builders/SlashCommandBuilder.js +0 -204
- package/bin/mjs/reciple/flags.js +0 -28
- package/bin/mjs/reciple/logger.js +0 -28
- package/bin/mjs/reciple/modules.js +0 -81
- package/bin/mjs/reciple/permissions.js +0 -23
- package/bin/mjs/reciple/types/builders.js +0 -8
- package/bin/mjs/reciple/types/commands.js +0 -12
- package/bin/mjs/reciple/types/paramOptions.js +0 -1
- package/bin/mjs/reciple/util.js +0 -7
- package/bin/mjs/reciple/version.js +0 -38
package/bin/mjs/reciple/flags.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { rawVersion } from './version.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
/**
|
|
4
|
-
* Commander
|
|
5
|
-
*/
|
|
6
|
-
export const commander = new Command()
|
|
7
|
-
.name('reciple')
|
|
8
|
-
.description('Reciple.js - Discord.js handler cli')
|
|
9
|
-
.version(`v${rawVersion}`, '-v, --version')
|
|
10
|
-
.argument('[current-working-directory]', 'Change the current working directory')
|
|
11
|
-
.option('-t, --token <token>', 'Replace used bot token')
|
|
12
|
-
.option('-c, --config <config>', 'Change path to config file')
|
|
13
|
-
.option('-D, --debugmode', 'Enable debug mode')
|
|
14
|
-
.option('-y, --yes', 'Automatically agree to Reciple confirmation prompts')
|
|
15
|
-
.option('-v, --version', 'Display version')
|
|
16
|
-
.parse();
|
|
17
|
-
/**
|
|
18
|
-
* Used flags
|
|
19
|
-
*/
|
|
20
|
-
export const flags = commander.opts();
|
|
21
|
-
/**
|
|
22
|
-
* Token flag
|
|
23
|
-
*/
|
|
24
|
-
export const token = flags.token;
|
|
25
|
-
/**
|
|
26
|
-
* Current working directory
|
|
27
|
-
*/
|
|
28
|
-
export const cwd = commander.args[0] || process.cwd();
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Logger, LogLevels } from 'fallout-utility';
|
|
2
|
-
import { flags } from './flags.js';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
/**
|
|
5
|
-
* Create new logger
|
|
6
|
-
* @param stringifyJSON stringify json objects in console
|
|
7
|
-
* @param debugmode display debug messages
|
|
8
|
-
* @param colorizeMessage add logger colours to messages
|
|
9
|
-
*/
|
|
10
|
-
export function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true) {
|
|
11
|
-
return new Logger({
|
|
12
|
-
stringifyJSON: stringifyJSON,
|
|
13
|
-
enableDebugMode: flags.debugmode ?? debugmode,
|
|
14
|
-
loggerName: 'Main',
|
|
15
|
-
prefixes: {
|
|
16
|
-
[LogLevels.INFO]: (name) => `[${new Date().toLocaleTimeString(undefined, { hour12: false })}][${(name ? name + "/" : '') + "INFO"}]`,
|
|
17
|
-
[LogLevels.WARN]: (name) => `[${chalk.yellow(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk.yellow((name ? name + "/" : '') + "WARN")}]`,
|
|
18
|
-
[LogLevels.ERROR]: (name) => `[${chalk.red(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk.red((name ? name + "/" : '') + "ERROR")}]`,
|
|
19
|
-
[LogLevels.DEBUG]: (name) => `[${chalk.blue(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk.blue((name ? name + "/" : '') + "DEBUG")}]`
|
|
20
|
-
},
|
|
21
|
-
colorMessages: {
|
|
22
|
-
[LogLevels.INFO]: (message) => message,
|
|
23
|
-
[LogLevels.WARN]: (message) => !colorizeMessage ? message : chalk.yellow(message),
|
|
24
|
-
[LogLevels.ERROR]: (message) => !colorizeMessage ? message : chalk.red(message),
|
|
25
|
-
[LogLevels.DEBUG]: (message) => !colorizeMessage ? message : chalk.blue(message)
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { CommandBuilderType } from './types/builders.js';
|
|
2
|
-
import { MessageCommandBuilder } from './classes/builders/MessageCommandBuilder.js';
|
|
3
|
-
import { SlashCommandBuilder } from './classes/builders/SlashCommandBuilder.js';
|
|
4
|
-
import { normalizeArray } from 'discord.js';
|
|
5
|
-
import { isSupportedVersion, version } from './version.js';
|
|
6
|
-
import { existsSync, mkdirSync, readdirSync } from 'fs';
|
|
7
|
-
import wildcard from 'wildcard-match';
|
|
8
|
-
import { cwd } from './flags.js';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
/**
|
|
11
|
-
* Load modules from folder
|
|
12
|
-
* @param client Reciple client
|
|
13
|
-
* @param folder Modules folder
|
|
14
|
-
*/
|
|
15
|
-
export async function getModules(client, folder) {
|
|
16
|
-
const response = { commands: [], modules: [] };
|
|
17
|
-
const modulesDir = folder || path.join(cwd, 'modules');
|
|
18
|
-
if (!existsSync(modulesDir))
|
|
19
|
-
mkdirSync(modulesDir, { recursive: true });
|
|
20
|
-
const ignoredFiles = (client.config.ignoredFiles || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
|
|
21
|
-
const scripts = readdirSync(modulesDir).filter(file => {
|
|
22
|
-
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => wildcard(f)(file));
|
|
23
|
-
});
|
|
24
|
-
for (const script of scripts) {
|
|
25
|
-
const modulePath = path.join(modulesDir, script);
|
|
26
|
-
const commands = [];
|
|
27
|
-
let module_;
|
|
28
|
-
try {
|
|
29
|
-
const reqMod = require(modulePath);
|
|
30
|
-
module_ = reqMod?.default !== undefined ? reqMod.default : reqMod;
|
|
31
|
-
if (!module_?.versions.length)
|
|
32
|
-
throw new Error(`${modulePath} does not have supported versions.`);
|
|
33
|
-
const versions = normalizeArray([module_.versions]);
|
|
34
|
-
if (!client.config.disableVersionCheck && !versions.some(v => isSupportedVersion(v, version)))
|
|
35
|
-
throw new Error(`${modulePath} is unsupported; current version: ${version}; module supported versions: ` + versions.join(', ') ?? 'none');
|
|
36
|
-
if (!await Promise.resolve(module_.onStart(client)).catch(() => null))
|
|
37
|
-
throw new Error(script + ' onStart returned false or undefined.');
|
|
38
|
-
if (module_.commands) {
|
|
39
|
-
for (const command of module_.commands) {
|
|
40
|
-
if (command.type === CommandBuilderType.MessageCommand) {
|
|
41
|
-
commands.push(MessageCommandBuilder.resolveMessageCommand(command));
|
|
42
|
-
}
|
|
43
|
-
else if (command.type === CommandBuilderType.SlashCommand) {
|
|
44
|
-
commands.push(SlashCommandBuilder.resolveSlashCommand(command));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
if (client.isClientLogsEnabled()) {
|
|
51
|
-
client.logger.error(`Failed to load module ${script}`);
|
|
52
|
-
client.logger.error(error);
|
|
53
|
-
}
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
response.commands.push(...commands.filter((c) => {
|
|
57
|
-
if (!c.name) {
|
|
58
|
-
if (client.isClientLogsEnabled())
|
|
59
|
-
client.logger.error(`A ${CommandBuilderType[c.type]} command name is not defined in ${modulePath}`);
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
if (c.type === CommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
|
|
63
|
-
if (client.isClientLogsEnabled())
|
|
64
|
-
client.logger.error(`A ${CommandBuilderType[c.type]} option name is not defined in ${modulePath}`);
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}));
|
|
69
|
-
response.modules.push({
|
|
70
|
-
script: module_,
|
|
71
|
-
info: {
|
|
72
|
-
filename: script,
|
|
73
|
-
versions: normalizeArray([module_.versions]),
|
|
74
|
-
path: modulePath
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
if (client.isClientLogsEnabled())
|
|
78
|
-
client.logger.info(`Loaded module ${modulePath}`);
|
|
79
|
-
}
|
|
80
|
-
return response;
|
|
81
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if the user has permissions to execute the given command name
|
|
3
|
-
* @param options options
|
|
4
|
-
*/
|
|
5
|
-
export function userHasCommandPermissions(options) {
|
|
6
|
-
const command = (options.commandPermissions?.enabled
|
|
7
|
-
? options.commandPermissions?.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase())
|
|
8
|
-
: null)
|
|
9
|
-
?? { permissions: options.builder.requiredMemberPermissions };
|
|
10
|
-
if (!command.permissions.length)
|
|
11
|
-
return true;
|
|
12
|
-
return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Check if the bot has the required permissions in a guild
|
|
16
|
-
* @param guild Guild
|
|
17
|
-
* @param requiredPermissions Required guild bot permissions
|
|
18
|
-
*/
|
|
19
|
-
export function botHasExecutePermissions(guild, requiredPermissions) {
|
|
20
|
-
if (!requiredPermissions?.length)
|
|
21
|
-
return true;
|
|
22
|
-
return guild?.members.me ? guild.members.me.permissions.has(requiredPermissions) : false;
|
|
23
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types of command builders
|
|
3
|
-
*/
|
|
4
|
-
export var CommandBuilderType;
|
|
5
|
-
(function (CommandBuilderType) {
|
|
6
|
-
CommandBuilderType[CommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
|
|
7
|
-
CommandBuilderType[CommandBuilderType["SlashCommand"] = 1] = "SlashCommand";
|
|
8
|
-
})(CommandBuilderType || (CommandBuilderType = {}));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Command halt reasons
|
|
3
|
-
*/
|
|
4
|
-
export var CommandHaltReason;
|
|
5
|
-
(function (CommandHaltReason) {
|
|
6
|
-
CommandHaltReason[CommandHaltReason["Error"] = 0] = "Error";
|
|
7
|
-
CommandHaltReason[CommandHaltReason["Cooldown"] = 1] = "Cooldown";
|
|
8
|
-
CommandHaltReason[CommandHaltReason["InvalidArguments"] = 2] = "InvalidArguments";
|
|
9
|
-
CommandHaltReason[CommandHaltReason["MissingArguments"] = 3] = "MissingArguments";
|
|
10
|
-
CommandHaltReason[CommandHaltReason["MissingMemberPermissions"] = 4] = "MissingMemberPermissions";
|
|
11
|
-
CommandHaltReason[CommandHaltReason["MissingBotPermissions"] = 5] = "MissingBotPermissions";
|
|
12
|
-
})(CommandHaltReason || (CommandHaltReason = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/bin/mjs/reciple/util.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function isClass(object) {
|
|
2
|
-
const isClassConstructor = object.constructor && object.constructor.toString().substring(0, 5) === 'class';
|
|
3
|
-
if (object.prototype === undefined)
|
|
4
|
-
return isClassConstructor;
|
|
5
|
-
const isPrototypeClassConstructor = object.prototype.constructor && object.prototype.constructor.toString && object.prototype.constructor.toString().substring(0, 5) === 'class';
|
|
6
|
-
return isClassConstructor || isPrototypeClassConstructor;
|
|
7
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
|
-
/**
|
|
3
|
-
* Current reciple version
|
|
4
|
-
*/
|
|
5
|
-
export const version = `${semver.coerce(require('../../package.json').version)}`;
|
|
6
|
-
/**
|
|
7
|
-
* Current reciple version from package.json
|
|
8
|
-
*/
|
|
9
|
-
export const rawVersion = require('../../package.json').version;
|
|
10
|
-
/**
|
|
11
|
-
* Check if the version is valid
|
|
12
|
-
* @param ver Version string to validated
|
|
13
|
-
*/
|
|
14
|
-
export function isValidVersion(ver) {
|
|
15
|
-
return semver.valid(semver.coerce(ver)) !== null;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Parse the version string
|
|
19
|
-
* @param ver Parse version string
|
|
20
|
-
*/
|
|
21
|
-
export function parseVersion(ver) {
|
|
22
|
-
if (!isValidVersion(ver))
|
|
23
|
-
throw new TypeError(`Invalid version: ${ver}`);
|
|
24
|
-
return semver.parse(ver);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Check if the given version is supported by the given version range
|
|
28
|
-
* @param versionRange Version range
|
|
29
|
-
* @param supportedVersion Version to match given version range
|
|
30
|
-
*/
|
|
31
|
-
export function isSupportedVersion(versionRange, supportedVersion) {
|
|
32
|
-
supportedVersion = supportedVersion || version;
|
|
33
|
-
if (!isValidVersion(versionRange))
|
|
34
|
-
throw new TypeError(`Invalid version: ${versionRange}`);
|
|
35
|
-
if (!isValidVersion(supportedVersion))
|
|
36
|
-
throw new TypeError(`Invalid supported version: ${supportedVersion}`);
|
|
37
|
-
return semver.satisfies(supportedVersion, versionRange);
|
|
38
|
-
}
|