reciple 5.4.0 → 5.4.1-pre.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/{bin.js → cjs/bin.js} +0 -0
- package/bin/{index.js → cjs/index.js} +0 -0
- package/bin/cjs/package.json +3 -0
- package/bin/{reciple → cjs/reciple}/classes/CommandCooldownManager.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/MessageCommandOptionManager.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/RecipleClient.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/RecipleConfig.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/builders/MessageCommandBuilder.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/builders/MessageCommandOptionBuilder.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/builders/SlashCommandBuilder.js +0 -0
- package/bin/{reciple → cjs/reciple}/flags.js +0 -0
- package/bin/{reciple → cjs/reciple}/logger.js +0 -0
- package/bin/{reciple → cjs/reciple}/modules.js +0 -0
- package/bin/{reciple → cjs/reciple}/permissions.js +0 -0
- package/bin/{reciple → cjs/reciple}/registerApplicationCommands.js +0 -0
- package/bin/{reciple → cjs/reciple}/types/builders.js +0 -0
- package/bin/{reciple → cjs/reciple}/types/commands.js +0 -0
- package/bin/{reciple → cjs/reciple}/types/paramOptions.js +0 -0
- package/bin/{reciple → cjs/reciple}/util.js +0 -0
- package/bin/{reciple → cjs/reciple}/version.js +0 -0
- package/bin/mjs/bin.js +46 -0
- package/bin/{index.d.ts → mjs/index.js} +0 -0
- package/bin/mjs/package.json +3 -0
- package/bin/mjs/reciple/classes/CommandCooldownManager.js +87 -0
- package/bin/mjs/reciple/classes/MessageCommandOptionManager.js +21 -0
- package/bin/mjs/reciple/classes/RecipleClient.js +363 -0
- package/bin/mjs/reciple/classes/RecipleConfig.js +92 -0
- package/bin/mjs/reciple/classes/builders/MessageCommandBuilder.js +218 -0
- package/bin/mjs/reciple/classes/builders/MessageCommandOptionBuilder.js +67 -0
- package/bin/mjs/reciple/classes/builders/SlashCommandBuilder.js +204 -0
- package/bin/mjs/reciple/flags.js +28 -0
- package/bin/mjs/reciple/logger.js +28 -0
- package/bin/mjs/reciple/modules.js +81 -0
- package/bin/mjs/reciple/permissions.js +23 -0
- package/bin/mjs/reciple/registerApplicationCommands.js +47 -0
- package/bin/mjs/reciple/types/builders.js +8 -0
- package/bin/mjs/reciple/types/commands.js +12 -0
- package/bin/mjs/reciple/types/paramOptions.js +1 -0
- package/bin/mjs/reciple/util.js +7 -0
- package/bin/mjs/reciple/version.js +38 -0
- package/bin/{bin.d.ts → types/bin.d.ts} +0 -0
- package/bin/types/index.d.ts +17 -0
- package/bin/{reciple → types/reciple}/classes/CommandCooldownManager.d.ts +0 -0
- package/bin/{reciple → types/reciple}/classes/MessageCommandOptionManager.d.ts +0 -0
- package/bin/{reciple → types/reciple}/classes/RecipleClient.d.ts +0 -0
- package/bin/{reciple → types/reciple}/classes/RecipleConfig.d.ts +0 -0
- package/bin/{reciple → types/reciple}/classes/builders/MessageCommandBuilder.d.ts +0 -0
- package/bin/{reciple → types/reciple}/classes/builders/MessageCommandOptionBuilder.d.ts +0 -0
- package/bin/{reciple → types/reciple}/classes/builders/SlashCommandBuilder.d.ts +0 -0
- package/bin/{reciple → types/reciple}/flags.d.ts +0 -0
- package/bin/{reciple → types/reciple}/logger.d.ts +0 -0
- package/bin/{reciple → types/reciple}/modules.d.ts +0 -0
- package/bin/{reciple → types/reciple}/permissions.d.ts +0 -0
- package/bin/{reciple → types/reciple}/registerApplicationCommands.d.ts +0 -0
- package/bin/{reciple → types/reciple}/types/builders.d.ts +1 -1
- package/bin/{reciple → types/reciple}/types/commands.d.ts +0 -0
- package/bin/{reciple → types/reciple}/types/paramOptions.d.ts +0 -0
- package/bin/{reciple → types/reciple}/util.d.ts +0 -0
- package/bin/{reciple → types/reciple}/version.d.ts +0 -0
- package/package.json +13 -8
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { normalizeArray } from 'discord.js.js';
|
|
2
|
+
import { SlashCommandBuilder } from './classes/builders/SlashCommandBuilder.js';
|
|
3
|
+
/**
|
|
4
|
+
* Register application commands
|
|
5
|
+
* @param options Register application commands options
|
|
6
|
+
*/
|
|
7
|
+
export async function registerApplicationCommands(options) {
|
|
8
|
+
const client = options.client;
|
|
9
|
+
const guilds = normalizeArray(options.guilds);
|
|
10
|
+
const commands = Object.values(options.commands ?? client.commands.slashCommands).map(cmd => {
|
|
11
|
+
if (typeof cmd?.toJSON == 'undefined')
|
|
12
|
+
return cmd;
|
|
13
|
+
cmd = cmd;
|
|
14
|
+
if (SlashCommandBuilder.isSlashCommandBuilder(cmd) && client.config.commands.slashCommand.setRequiredPermissions) {
|
|
15
|
+
const permissions = client.config.commands.slashCommand.permissions.enabled
|
|
16
|
+
? client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions
|
|
17
|
+
: undefined;
|
|
18
|
+
if (permissions) {
|
|
19
|
+
cmd.setRequiredMemberPermissions(...permissions);
|
|
20
|
+
if (client.isClientLogsEnabled())
|
|
21
|
+
client.logger.debug(`Set required permissions for ${cmd.name}`);
|
|
22
|
+
}
|
|
23
|
+
client.commands.slashCommands[cmd.name] = cmd;
|
|
24
|
+
}
|
|
25
|
+
return cmd.toJSON();
|
|
26
|
+
}) ?? [];
|
|
27
|
+
if (!client.isReady())
|
|
28
|
+
throw new Error('Client is not ready');
|
|
29
|
+
if (!guilds || !guilds?.length) {
|
|
30
|
+
client.application?.commands.set(commands).then(() => {
|
|
31
|
+
if (client.isClientLogsEnabled())
|
|
32
|
+
client.logger.warn('No guilds were specified for application commands. Registered application commands globally.');
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (client.isClientLogsEnabled())
|
|
37
|
+
client.logger.warn(`Registering ${commands.length} application commands to ${guilds.length} guild(s).`);
|
|
38
|
+
for (const guild of guilds) {
|
|
39
|
+
if (!guild)
|
|
40
|
+
continue;
|
|
41
|
+
client.application?.commands.set(commands, guild).then(() => {
|
|
42
|
+
if (client.isClientLogsEnabled())
|
|
43
|
+
client.logger.warn(`Registered ${commands.length} application command(s) for ${guild}.`);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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 = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
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 = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import semver from 'semver.js';
|
|
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
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './reciple/classes/CommandCooldownManager';
|
|
2
|
+
export * from './reciple/classes/MessageCommandOptionManager';
|
|
3
|
+
export * from './reciple/classes/RecipleClient';
|
|
4
|
+
export * from './reciple/classes/RecipleConfig';
|
|
5
|
+
export * from './reciple/classes/builders/MessageCommandBuilder';
|
|
6
|
+
export * from './reciple/classes/builders/MessageCommandOptionBuilder';
|
|
7
|
+
export * from './reciple/classes/builders/SlashCommandBuilder';
|
|
8
|
+
export * from './reciple/types/builders';
|
|
9
|
+
export * from './reciple/types/commands';
|
|
10
|
+
export * from './reciple/types/paramOptions';
|
|
11
|
+
export * from './reciple/flags';
|
|
12
|
+
export * from './reciple/logger';
|
|
13
|
+
export * from './reciple/modules';
|
|
14
|
+
export * from './reciple/permissions';
|
|
15
|
+
export * from './reciple/registerApplicationCommands';
|
|
16
|
+
export * from './reciple/util';
|
|
17
|
+
export * from './reciple/version';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -180,7 +180,7 @@ export interface MessageCommandData extends SharedCommandDataProperties, Partial
|
|
|
180
180
|
allowExecuteByBots?: boolean;
|
|
181
181
|
halt?: MessageCommandHaltFunction;
|
|
182
182
|
execute: MessageCommandExecuteFunction;
|
|
183
|
-
options
|
|
183
|
+
options?: MessageCommandOptionResolvable[];
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* Message command option object data interface
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "5.4.
|
|
4
|
-
"bin": "bin/bin.js",
|
|
3
|
+
"version": "5.4.1-pre.3",
|
|
5
4
|
"license": "GPL-3.0",
|
|
6
|
-
"
|
|
7
|
-
"typings": "bin/index.d.ts",
|
|
5
|
+
"typings": "bin/types/index.d.ts",
|
|
8
6
|
"author": "FalloutStudios",
|
|
9
7
|
"description": "Handler for Discord.js",
|
|
10
8
|
"homepage": "https://reciple.js.org",
|
|
9
|
+
"main": "./bin/cjs/index.js",
|
|
10
|
+
"module": "./bin/mjs/index.js",
|
|
11
|
+
"bin": "./bin/cjs/bin.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
"import": "./bin/mjs/index.js",
|
|
14
|
+
"require": "./bin/cjs/index.js"
|
|
15
|
+
},
|
|
11
16
|
"keywords": [
|
|
12
17
|
"Discord",
|
|
13
18
|
"Discord.js handler",
|
|
@@ -21,7 +26,7 @@
|
|
|
21
26
|
},
|
|
22
27
|
"scripts": {
|
|
23
28
|
"clean": "yarn exec rimraf bin",
|
|
24
|
-
"build": "yarn clean && yarn exec tsc",
|
|
29
|
+
"build": "yarn clean && echo Building commonjs && yarn exec tsc -p ./tsconfigs/tsconfig-cjs.json && echo Building mjs && yarn exec tsc -p ./tsconfigs/tsconfig-mjs.json && node ./tsconfigs/package.json.js",
|
|
25
30
|
"build:publish": "yarn build && yarn npm publish && yarn build:docs && yarn publish:docs",
|
|
26
31
|
"build:publish-prerelease": "yarn build && yarn npm publish --tag pre",
|
|
27
32
|
"build:docs": "yarn exec typedoc --tsconfig ./docs/typedoc.json",
|
|
@@ -57,15 +62,15 @@
|
|
|
57
62
|
"yaml": "^2.1.1"
|
|
58
63
|
},
|
|
59
64
|
"devDependencies": {
|
|
60
|
-
"@types/node": "^18.7.
|
|
65
|
+
"@types/node": "^18.7.13",
|
|
61
66
|
"@types/semver": "^7.3.12",
|
|
62
67
|
"discord.js": "^14.3.0",
|
|
63
68
|
"rimraf": "^3.0.2",
|
|
64
|
-
"typedoc": "^0.23.
|
|
69
|
+
"typedoc": "^0.23.11",
|
|
65
70
|
"typedoc-plugin-discord-types": "^1.0.2",
|
|
66
71
|
"typedoc-plugin-djs-links": "^1.2.0",
|
|
67
72
|
"typedoc-plugin-mdn-links": "^2.0.0",
|
|
68
|
-
"typescript": "^4.
|
|
73
|
+
"typescript": "^4.8.2"
|
|
69
74
|
},
|
|
70
75
|
"peerDependencies": {
|
|
71
76
|
"discord.js": "^14.2.0"
|