reciple 5.4.0-pre.2 → 5.4.1-pre.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/{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 +3 -3
- package/bin/{reciple → cjs/reciple}/classes/RecipleConfig.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/builders/MessageCommandBuilder.js +2 -3
- package/bin/{reciple → cjs/reciple}/classes/builders/MessageCommandOptionBuilder.js +0 -0
- package/bin/{reciple → cjs/reciple}/classes/builders/SlashCommandBuilder.js +15 -16
- 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 +2 -2
- 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/cjs/reciple/util.js +11 -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 +1 -1
- 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 +30 -34
- 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 +15 -8
- package/bin/reciple/util.js +0 -11
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.RecipleClient = void 0;
|
|
16
16
|
const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
|
|
17
17
|
const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
|
|
18
|
-
const registerApplicationCommands_1 = require("../registerApplicationCommands");
|
|
19
18
|
const builders_1 = require("../types/builders");
|
|
19
|
+
const registerApplicationCommands_1 = require("../registerApplicationCommands");
|
|
20
20
|
const commands_1 = require("../types/commands");
|
|
21
21
|
const permissions_1 = require("../permissions");
|
|
22
22
|
const CommandCooldownManager_1 = require("./CommandCooldownManager");
|
|
@@ -26,9 +26,9 @@ const RecipleConfig_1 = require("./RecipleConfig");
|
|
|
26
26
|
const modules_1 = require("../modules");
|
|
27
27
|
const logger_1 = require("../logger");
|
|
28
28
|
const version_1 = require("../version");
|
|
29
|
-
const discord_js_1 = require("discord.js");
|
|
30
|
-
const path_1 = __importDefault(require("path"));
|
|
31
29
|
const flags_1 = require("../flags");
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const discord_js_1 = require("discord.js");
|
|
32
32
|
class RecipleClient extends discord_js_1.Client {
|
|
33
33
|
/**
|
|
34
34
|
* @param options Client options
|
|
File without changes
|
|
@@ -14,7 +14,6 @@ const builders_1 = require("../../types/builders");
|
|
|
14
14
|
const discord_js_1 = require("discord.js");
|
|
15
15
|
const MessageCommandOptionManager_1 = require("../MessageCommandOptionManager");
|
|
16
16
|
const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
17
|
-
const fallout_utility_1 = require("fallout-utility");
|
|
18
17
|
/**
|
|
19
18
|
* Reciple builder for message command
|
|
20
19
|
*/
|
|
@@ -36,8 +35,8 @@ class MessageCommandBuilder {
|
|
|
36
35
|
this.setName(data.name);
|
|
37
36
|
if ((data === null || data === void 0 ? void 0 : data.description) !== undefined)
|
|
38
37
|
this.setDescription(data.description);
|
|
39
|
-
if ((
|
|
40
|
-
this.setCooldown(data === null || data === void 0 ? void 0 : data.cooldown);
|
|
38
|
+
if ((data === null || data === void 0 ? void 0 : data.cooldown) !== undefined)
|
|
39
|
+
this.setCooldown(Number(data === null || data === void 0 ? void 0 : data.cooldown));
|
|
41
40
|
if ((data === null || data === void 0 ? void 0 : data.requiredBotPermissions) !== undefined)
|
|
42
41
|
this.setRequiredBotPermissions(data.requiredBotPermissions);
|
|
43
42
|
if ((data === null || data === void 0 ? void 0 : data.requiredMemberPermissions) !== undefined)
|
|
File without changes
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SlashCommandBuilder = void 0;
|
|
4
4
|
const builders_1 = require("../../types/builders");
|
|
5
|
-
const discord_js_1 = require("discord.js");
|
|
6
|
-
const fallout_utility_1 = require("fallout-utility");
|
|
7
5
|
const util_1 = require("../../util");
|
|
6
|
+
const discord_js_1 = require("discord.js");
|
|
8
7
|
/**
|
|
9
8
|
* Reciple builder for slash command
|
|
10
9
|
*/
|
|
@@ -20,8 +19,8 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
20
19
|
this.setName(data.name);
|
|
21
20
|
if ((data === null || data === void 0 ? void 0 : data.description) !== undefined)
|
|
22
21
|
this.setDescription(data.description);
|
|
23
|
-
if ((
|
|
24
|
-
this.setCooldown(data === null || data === void 0 ? void 0 : data.cooldown);
|
|
22
|
+
if ((data === null || data === void 0 ? void 0 : data.cooldown) !== undefined)
|
|
23
|
+
this.setCooldown(Number(data === null || data === void 0 ? void 0 : data.cooldown));
|
|
25
24
|
if ((data === null || data === void 0 ? void 0 : data.requiredBotPermissions) !== undefined)
|
|
26
25
|
this.setRequiredBotPermissions(data.requiredBotPermissions);
|
|
27
26
|
if ((data === null || data === void 0 ? void 0 : data.requiredMemberPermissions) !== undefined)
|
|
@@ -72,14 +71,8 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
72
71
|
* Add option builder to command builder
|
|
73
72
|
*/
|
|
74
73
|
static addOption(builder, option) {
|
|
75
|
-
if (option instanceof discord_js_1.
|
|
76
|
-
builder.
|
|
77
|
-
}
|
|
78
|
-
else if (option instanceof discord_js_1.SlashCommandNumberOption) {
|
|
79
|
-
builder.addNumberOption(option);
|
|
80
|
-
}
|
|
81
|
-
else if (option instanceof discord_js_1.SlashCommandIntegerOption) {
|
|
82
|
-
builder.addIntegerOption(option);
|
|
74
|
+
if (option instanceof discord_js_1.SlashCommandAttachmentOption) {
|
|
75
|
+
builder.addAttachmentOption(option);
|
|
83
76
|
}
|
|
84
77
|
else if (option instanceof discord_js_1.SlashCommandBooleanOption) {
|
|
85
78
|
builder.addBooleanOption(option);
|
|
@@ -87,17 +80,23 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
87
80
|
else if (option instanceof discord_js_1.SlashCommandChannelOption) {
|
|
88
81
|
builder.addChannelOption(option);
|
|
89
82
|
}
|
|
83
|
+
else if (option instanceof discord_js_1.SlashCommandIntegerOption) {
|
|
84
|
+
builder.addIntegerOption(option);
|
|
85
|
+
}
|
|
90
86
|
else if (option instanceof discord_js_1.SlashCommandMentionableOption) {
|
|
91
87
|
builder.addMentionableOption(option);
|
|
92
88
|
}
|
|
93
|
-
else if (option instanceof discord_js_1.
|
|
94
|
-
builder.
|
|
89
|
+
else if (option instanceof discord_js_1.SlashCommandNumberOption) {
|
|
90
|
+
builder.addNumberOption(option);
|
|
95
91
|
}
|
|
96
92
|
else if (option instanceof discord_js_1.SlashCommandRoleOption) {
|
|
97
93
|
builder.addRoleOption(option);
|
|
98
94
|
}
|
|
99
|
-
else if (option instanceof discord_js_1.
|
|
100
|
-
builder.
|
|
95
|
+
else if (option instanceof discord_js_1.SlashCommandStringOption) {
|
|
96
|
+
builder.addStringOption(option);
|
|
97
|
+
}
|
|
98
|
+
else if (option instanceof discord_js_1.SlashCommandUserOption) {
|
|
99
|
+
builder.addUserOption(option);
|
|
101
100
|
}
|
|
102
101
|
else if (builder instanceof SlashCommandBuilder) {
|
|
103
102
|
if (option instanceof discord_js_1.SlashCommandSubcommandBuilder) {
|
|
File without changes
|
|
File without changes
|
|
@@ -14,14 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getModules = void 0;
|
|
16
16
|
const builders_1 = require("./types/builders");
|
|
17
|
+
const MessageCommandBuilder_1 = require("./classes/builders/MessageCommandBuilder");
|
|
18
|
+
const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
|
|
17
19
|
const discord_js_1 = require("discord.js");
|
|
18
20
|
const version_1 = require("./version");
|
|
19
21
|
const fs_1 = require("fs");
|
|
20
22
|
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
21
23
|
const flags_1 = require("./flags");
|
|
22
24
|
const path_1 = __importDefault(require("path"));
|
|
23
|
-
const MessageCommandBuilder_1 = require("./classes/builders/MessageCommandBuilder");
|
|
24
|
-
const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
|
|
25
25
|
/**
|
|
26
26
|
* Load modules from folder
|
|
27
27
|
* @param client Reciple client
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClass = void 0;
|
|
4
|
+
function isClass(object) {
|
|
5
|
+
const isClassConstructor = object.constructor && object.constructor.toString().substring(0, 5) === 'class';
|
|
6
|
+
if (object.prototype === undefined)
|
|
7
|
+
return isClassConstructor;
|
|
8
|
+
const isPrototypeClassConstructor = object.prototype.constructor && object.prototype.constructor.toString && object.prototype.constructor.toString().substring(0, 5) === 'class';
|
|
9
|
+
return isClassConstructor || isPrototypeClassConstructor;
|
|
10
|
+
}
|
|
11
|
+
exports.isClass = isClass;
|
|
File without changes
|
package/bin/mjs/bin.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { RecipleClient } from './reciple/classes/RecipleClient';
|
|
3
|
+
import { RecipleConfig } from './reciple/classes/RecipleConfig';
|
|
4
|
+
import { rawVersion } from './reciple/version';
|
|
5
|
+
import { existsSync, readdirSync } from 'fs';
|
|
6
|
+
import { cwd, flags } from './reciple/flags';
|
|
7
|
+
import { input } from 'fallout-utility';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import 'dotenv/config';
|
|
10
|
+
import { normalizeArray } from 'discord.js';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
|
|
13
|
+
const configPath = path.join(cwd, './reciple.yml');
|
|
14
|
+
if (readdirSync(cwd).filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !existsSync(flags.config ?? configPath)) {
|
|
15
|
+
const ask = (flags.yes ? 'y' : null) ?? input('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ') ?? '';
|
|
16
|
+
if (ask.toString().toLowerCase() !== 'y')
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
let configParser;
|
|
20
|
+
try {
|
|
21
|
+
configParser = new RecipleConfig(flags.config ?? configPath).parseConfig();
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.error(`${chalk.bold.red('Config Error')}: ${chalk.white(err.message)}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const config = configParser.getConfig();
|
|
28
|
+
const client = new RecipleClient({ config: config, ...config.client });
|
|
29
|
+
if (config.fileLogging.clientLogs)
|
|
30
|
+
client.logger.info('Starting Reciple client v' + rawVersion);
|
|
31
|
+
(async () => {
|
|
32
|
+
await client.startModules(normalizeArray(config.modulesFolder));
|
|
33
|
+
client.on('ready', async () => {
|
|
34
|
+
if (client.isClientLogsEnabled())
|
|
35
|
+
client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
|
|
36
|
+
client.on('cacheSweep', () => {
|
|
37
|
+
client.cooldowns.clean();
|
|
38
|
+
});
|
|
39
|
+
await client.loadModules();
|
|
40
|
+
client.addCommandListeners();
|
|
41
|
+
});
|
|
42
|
+
client.login(config.token).catch(err => {
|
|
43
|
+
if (client.isClientLogsEnabled())
|
|
44
|
+
client.logger.error(err);
|
|
45
|
+
});
|
|
46
|
+
})();
|
|
File without changes
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { normalizeArray } from 'discord.js';
|
|
2
|
+
/**
|
|
3
|
+
* cooled-down users manager
|
|
4
|
+
*/
|
|
5
|
+
export class CommandCooldownManager extends Array {
|
|
6
|
+
constructor(...data) {
|
|
7
|
+
super(...normalizeArray(data));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Alias for `CommandCooldownManager#push()`
|
|
11
|
+
* @param options Cooled-down user data
|
|
12
|
+
*/
|
|
13
|
+
add(...options) {
|
|
14
|
+
return this.push(...options);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Remove cooldown from specific user, channel or guild
|
|
18
|
+
* @param options Remove cooldown data options
|
|
19
|
+
* @param limit Remove cooldown data limit
|
|
20
|
+
*/
|
|
21
|
+
remove(options, limit = 0) {
|
|
22
|
+
if (!Object.keys(options).length)
|
|
23
|
+
throw new TypeError('Provide atleast one option to remove cooldown data.');
|
|
24
|
+
let i = 0;
|
|
25
|
+
for (const index in this) {
|
|
26
|
+
if (!CommandCooldownManager.checkOptions(options, this[index]))
|
|
27
|
+
continue;
|
|
28
|
+
if (options.expireTime && this[index].expireTime > Date.now())
|
|
29
|
+
continue;
|
|
30
|
+
if (limit && i >= limit)
|
|
31
|
+
continue;
|
|
32
|
+
this.splice(Number(index));
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if the given user is cooled-down
|
|
38
|
+
* @param options Options to identify if user is on cooldown
|
|
39
|
+
*/
|
|
40
|
+
isCooledDown(options) {
|
|
41
|
+
const data = this.get(options);
|
|
42
|
+
if (!data)
|
|
43
|
+
return false;
|
|
44
|
+
this.remove({ ...data, channel: undefined, guild: undefined, type: undefined, command: undefined });
|
|
45
|
+
if (data.expireTime < Date.now())
|
|
46
|
+
return false;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Purge non cooled-down users from this array
|
|
51
|
+
* @param options Clean cooldown options
|
|
52
|
+
*/
|
|
53
|
+
clean(options) {
|
|
54
|
+
for (const index in this) {
|
|
55
|
+
if (options && !CommandCooldownManager.checkOptions(options, this[index]))
|
|
56
|
+
return;
|
|
57
|
+
if (this[index].expireTime > Date.now())
|
|
58
|
+
return;
|
|
59
|
+
this.slice(Number(index));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get someone's cooldown data
|
|
64
|
+
* @param options Get cooldown data options
|
|
65
|
+
*/
|
|
66
|
+
get(options) {
|
|
67
|
+
return this.find(data => CommandCooldownManager.checkOptions(options, data));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if the options are valid
|
|
71
|
+
* @param options Options to validated
|
|
72
|
+
* @param data Cooled-down user data
|
|
73
|
+
*/
|
|
74
|
+
static checkOptions(options, data) {
|
|
75
|
+
if (options?.user && options.user.id !== data.user.id)
|
|
76
|
+
return false;
|
|
77
|
+
if (options?.guild && options.guild.id !== data.guild?.id)
|
|
78
|
+
return false;
|
|
79
|
+
if (options?.channel && options.channel.id !== data.channel?.id)
|
|
80
|
+
return false;
|
|
81
|
+
if (options?.command && options.command !== data.command)
|
|
82
|
+
return false;
|
|
83
|
+
if (options?.type && options.type !== data.type)
|
|
84
|
+
return false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { normalizeArray } from 'discord.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validated message options manager
|
|
4
|
+
*/
|
|
5
|
+
export class MessageCommandOptionManager extends Array {
|
|
6
|
+
constructor(...data) {
|
|
7
|
+
super(...normalizeArray(data));
|
|
8
|
+
}
|
|
9
|
+
get(name, required) {
|
|
10
|
+
const option = this.find(o => o.name == name);
|
|
11
|
+
if (!option?.value == undefined && required)
|
|
12
|
+
throw new TypeError(`Can't find option named ${name}`);
|
|
13
|
+
return option ?? null;
|
|
14
|
+
}
|
|
15
|
+
getValue(name, requied) {
|
|
16
|
+
const option = this.get(name, requied);
|
|
17
|
+
if (!option?.value && requied)
|
|
18
|
+
throw new TypeError(`Value of option named ${name} is undefined`);
|
|
19
|
+
return option?.value ?? null;
|
|
20
|
+
}
|
|
21
|
+
}
|