reciple 6.0.0-dev.7 → 6.0.0-dev.9
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/dist/cjs/bin.js +5 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/reciple/classes/RecipleClient.js +8 -8
- package/dist/cjs/reciple/classes/RecipleModule.js +11 -11
- package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +1 -1
- package/dist/cjs/reciple/classes/builders/SlashCommandBuilder.js +2 -5
- package/dist/cjs/reciple/classes/managers/ApplicationCommandManager.js +2 -4
- package/dist/cjs/reciple/classes/managers/ClientCommandManager.js +5 -6
- package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +6 -6
- package/dist/cjs/reciple/types/builders.js +6 -6
- package/dist/cjs/reciple/util.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/reciple/classes/RecipleModule.d.ts +2 -2
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +5 -5
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +5 -5
- package/dist/types/reciple/classes/managers/ClientCommandManager.d.ts +3 -3
- package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +2 -2
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +2 -2
- package/dist/types/reciple/types/builders.d.ts +6 -6
- package/dist/types/reciple/types/commands.d.ts +10 -10
- package/package.json +13 -12
- package/docs/README.md +0 -1
package/dist/cjs/bin.js
CHANGED
|
@@ -36,11 +36,13 @@ if (!client.isClientLogsSilent)
|
|
|
36
36
|
client.addCommandListeners();
|
|
37
37
|
await client.modules.startModules(await client.modules.getModulesFromFiles({
|
|
38
38
|
files: await client.modules.getModuleFiles(),
|
|
39
|
-
})
|
|
39
|
+
}));
|
|
40
40
|
client.on('ready', async () => {
|
|
41
|
-
await client.modules.loadModules(client.modules.modules.toJSON());
|
|
41
|
+
await client.modules.loadModules(client.modules.modules.toJSON(), true);
|
|
42
|
+
if (!client.isClientLogsSilent)
|
|
43
|
+
client.logger.log(`Loaded ${client.commands.slashCommands.size} slash commands`, `Loaded ${client.commands.messageCommands.size} message commands`);
|
|
42
44
|
if (client.config.commands.slashCommand.registerCommands)
|
|
43
|
-
client.commands.registerApplicationCommands();
|
|
45
|
+
await client.commands.registerApplicationCommands();
|
|
44
46
|
if (!client.isClientLogsSilent)
|
|
45
47
|
client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
|
|
46
48
|
client.on('cacheSweep', () => client.cooldowns.clean());
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,9 +18,9 @@ __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), export
|
|
|
18
18
|
__exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
|
|
19
19
|
__exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports);
|
|
20
20
|
__exportStar(require("./reciple/classes/managers/ApplicationCommandManager"), exports);
|
|
21
|
-
__exportStar(require("./reciple/classes/managers/CommandCooldownManager"), exports);
|
|
22
21
|
__exportStar(require("./reciple/classes/managers/ClientCommandManager"), exports);
|
|
23
22
|
__exportStar(require("./reciple/classes/managers/ClientModuleManager"), exports);
|
|
23
|
+
__exportStar(require("./reciple/classes/managers/CommandCooldownManager"), exports);
|
|
24
24
|
__exportStar(require("./reciple/classes/managers/MessageCommandOptionManager"), exports);
|
|
25
25
|
__exportStar(require("./reciple/classes/RecipleClient"), exports);
|
|
26
26
|
__exportStar(require("./reciple/classes/RecipleConfig"), exports);
|
|
@@ -12,9 +12,9 @@ const CommandCooldownManager_1 = require("./managers/CommandCooldownManager");
|
|
|
12
12
|
const permissions_1 = require("../permissions");
|
|
13
13
|
const MessageCommandOptionManager_1 = require("./managers/MessageCommandOptionManager");
|
|
14
14
|
const ApplicationCommandManager_1 = require("./managers/ApplicationCommandManager");
|
|
15
|
-
const builders_1 = require("../types/builders");
|
|
16
15
|
const ClientCommandManager_1 = require("./managers/ClientCommandManager");
|
|
17
16
|
const ClientModuleManager_1 = require("./managers/ClientModuleManager");
|
|
17
|
+
const builders_1 = require("../types/builders");
|
|
18
18
|
const RecipleConfig_1 = require("./RecipleConfig");
|
|
19
19
|
const fallout_utility_1 = require("fallout-utility");
|
|
20
20
|
const util_1 = require("../util");
|
|
@@ -68,7 +68,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
68
68
|
return;
|
|
69
69
|
if (!this.config.commands.slashCommand.acceptRepliedInteractions && (interaction.replied || interaction.deferred))
|
|
70
70
|
return;
|
|
71
|
-
const command = this.commands.get(interaction.commandName, builders_1.
|
|
71
|
+
const command = this.commands.get(interaction.commandName, builders_1.CommandType.SlashCommand);
|
|
72
72
|
if (!command)
|
|
73
73
|
return;
|
|
74
74
|
const executeData = {
|
|
@@ -97,7 +97,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
97
97
|
command: command.name,
|
|
98
98
|
channel: interaction.channel ?? undefined,
|
|
99
99
|
guild: interaction.guild,
|
|
100
|
-
type: builders_1.
|
|
100
|
+
type: builders_1.CommandType.SlashCommand,
|
|
101
101
|
};
|
|
102
102
|
if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
|
|
103
103
|
this.cooldowns.add({
|
|
@@ -135,7 +135,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
135
135
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.commands.messageCommand.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
|
|
136
136
|
if (!parseCommand || !parseCommand?.command)
|
|
137
137
|
return;
|
|
138
|
-
const command = this.commands.get(parseCommand.command, builders_1.
|
|
138
|
+
const command = this.commands.get(parseCommand.command, builders_1.CommandType.MessageCommand);
|
|
139
139
|
if (!command)
|
|
140
140
|
return;
|
|
141
141
|
const commandOptions = await (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
|
|
@@ -189,7 +189,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
189
189
|
command: command.name,
|
|
190
190
|
channel: message.channel,
|
|
191
191
|
guild: message.guild,
|
|
192
|
-
type: builders_1.
|
|
192
|
+
type: builders_1.CommandType.MessageCommand,
|
|
193
193
|
};
|
|
194
194
|
if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
|
|
195
195
|
this.cooldowns.add({
|
|
@@ -234,7 +234,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
234
234
|
async _haltCommand(command, haltData) {
|
|
235
235
|
try {
|
|
236
236
|
const haltResolved = (command.halt
|
|
237
|
-
? await Promise.resolve(command.type == builders_1.
|
|
237
|
+
? await Promise.resolve(command.type == builders_1.CommandType.SlashCommand ? command.halt(haltData) : command.halt(haltData)).catch(err => {
|
|
238
238
|
console.log(err);
|
|
239
239
|
})
|
|
240
240
|
: false) || false;
|
|
@@ -251,7 +251,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
251
251
|
}
|
|
252
252
|
async _executeCommand(command, executeData) {
|
|
253
253
|
try {
|
|
254
|
-
await Promise.resolve(command.type === builders_1.
|
|
254
|
+
await Promise.resolve(command.type === builders_1.CommandType.SlashCommand ? command.execute(executeData) : command.execute(executeData))
|
|
255
255
|
.then(() => this.emit('recipleCommandExecute', executeData))
|
|
256
256
|
.catch(async (err) => !(await this._haltCommand(command, {
|
|
257
257
|
executeData: executeData,
|
|
@@ -279,7 +279,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
279
279
|
*/
|
|
280
280
|
async _commandExecuteError(err, command) {
|
|
281
281
|
if (!this.isClientLogsSilent) {
|
|
282
|
-
this.logger.error(`An error occured executing ${command.builder.type == builders_1.
|
|
282
|
+
this.logger.error(`An error occured executing ${command.builder.type == builders_1.CommandType.MessageCommand ? 'message' : 'slash'} command "${command.builder.name}"`);
|
|
283
283
|
this.logger.error(err);
|
|
284
284
|
}
|
|
285
285
|
if (!err || !command)
|
|
@@ -19,29 +19,29 @@ class RecipleModule {
|
|
|
19
19
|
get displayName() {
|
|
20
20
|
return this.filePath ?? this.id;
|
|
21
21
|
}
|
|
22
|
-
async start(
|
|
23
|
-
if (resolveCommands)
|
|
24
|
-
this.resolveCommands();
|
|
22
|
+
async start() {
|
|
25
23
|
return Promise.resolve(this.script.onStart(this.client));
|
|
26
24
|
}
|
|
27
|
-
async load() {
|
|
25
|
+
async load(resolveCommands = true) {
|
|
28
26
|
if (typeof this.script.onLoad === 'function')
|
|
29
|
-
this.script.onLoad(this.client);
|
|
27
|
+
await this.script.onLoad(this.client);
|
|
28
|
+
if (resolveCommands)
|
|
29
|
+
this.resolveCommands();
|
|
30
30
|
}
|
|
31
31
|
async unLoad(reason) {
|
|
32
32
|
if (typeof this.script.onUnLoad === 'function')
|
|
33
|
-
this.script.onUnLoad(reason, this.client);
|
|
33
|
+
await this.script.onUnLoad(reason, this.client);
|
|
34
34
|
}
|
|
35
35
|
async registerSlashCommands(...guilds) {
|
|
36
36
|
for (const command of this.commands.toJSON()) {
|
|
37
|
-
if (command.type !== builders_1.
|
|
37
|
+
if (command.type !== builders_1.CommandType.SlashCommand)
|
|
38
38
|
continue;
|
|
39
39
|
await this.client.applicationCommands.add(command, (0, discord_js_1.normalizeArray)(guilds));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
async unregisterSlashCommands(...guilds) {
|
|
43
43
|
for (const builder of this.commands.toJSON()) {
|
|
44
|
-
if (builder.type !== builders_1.
|
|
44
|
+
if (builder.type !== builders_1.CommandType.SlashCommand)
|
|
45
45
|
continue;
|
|
46
46
|
if ((0, discord_js_1.normalizeArray)(guilds).length) {
|
|
47
47
|
for (const guild of (0, discord_js_1.normalizeArray)(guilds)) {
|
|
@@ -58,7 +58,7 @@ class RecipleModule {
|
|
|
58
58
|
}
|
|
59
59
|
async updateSlashCommands(...guilds) {
|
|
60
60
|
for (const builder of this.commands.toJSON()) {
|
|
61
|
-
if (builder.type !== builders_1.
|
|
61
|
+
if (builder.type !== builders_1.CommandType.SlashCommand)
|
|
62
62
|
continue;
|
|
63
63
|
if ((0, discord_js_1.normalizeArray)(guilds).length) {
|
|
64
64
|
for (const guild of (0, discord_js_1.normalizeArray)(guilds)) {
|
|
@@ -77,9 +77,9 @@ class RecipleModule {
|
|
|
77
77
|
if (!Array.isArray(this.script?.commands))
|
|
78
78
|
return this.commands;
|
|
79
79
|
for (const command of this.script.commands) {
|
|
80
|
-
if (command?.type !== builders_1.
|
|
80
|
+
if (command?.type !== builders_1.CommandType.SlashCommand && command?.type !== builders_1.CommandType.MessageCommand)
|
|
81
81
|
continue;
|
|
82
|
-
const builder = command.type === builders_1.
|
|
82
|
+
const builder = command.type === builders_1.CommandType.SlashCommand ? SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command) : MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command);
|
|
83
83
|
if (!(0, util_1.validateCommandBuilder)(builder))
|
|
84
84
|
throw new Error('Invalid command builder, no name or contains option(s) without name');
|
|
85
85
|
this.commands.set(command.name, builder);
|
|
@@ -10,7 +10,7 @@ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
|
10
10
|
*/
|
|
11
11
|
class MessageCommandBuilder {
|
|
12
12
|
constructor(data) {
|
|
13
|
-
this.type = builders_1.
|
|
13
|
+
this.type = builders_1.CommandType.MessageCommand;
|
|
14
14
|
this.name = '';
|
|
15
15
|
this.description = '';
|
|
16
16
|
this.cooldown = 0;
|
|
@@ -10,7 +10,7 @@ const discord_js_1 = require("discord.js");
|
|
|
10
10
|
class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
11
11
|
constructor(data) {
|
|
12
12
|
super();
|
|
13
|
-
this.type = builders_1.
|
|
13
|
+
this.type = builders_1.CommandType.SlashCommand;
|
|
14
14
|
this.cooldown = 0;
|
|
15
15
|
this.requiredBotPermissions = [];
|
|
16
16
|
this.requiredMemberPermissions = [];
|
|
@@ -182,10 +182,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
182
182
|
default:
|
|
183
183
|
throw new TypeError('Unknown option data');
|
|
184
184
|
}
|
|
185
|
-
if (!(builder instanceof discord_js_1.SlashCommandSubcommandBuilder) &&
|
|
186
|
-
!(builder instanceof discord_js_1.SlashCommandSubcommandGroupBuilder) &&
|
|
187
|
-
option.type !== discord_js_1.ApplicationCommandOptionType.Subcommand &&
|
|
188
|
-
option.type !== discord_js_1.ApplicationCommandOptionType.SubcommandGroup) {
|
|
185
|
+
if (!(builder instanceof discord_js_1.SlashCommandSubcommandBuilder) && !(builder instanceof discord_js_1.SlashCommandSubcommandGroupBuilder) && option.type !== discord_js_1.ApplicationCommandOptionType.Subcommand && option.type !== discord_js_1.ApplicationCommandOptionType.SubcommandGroup) {
|
|
189
186
|
builder.setRequired(option.required ?? false);
|
|
190
187
|
}
|
|
191
188
|
return builder
|
|
@@ -109,7 +109,7 @@ class ApplicationCommandManager {
|
|
|
109
109
|
const commands = guild ? this.client.guilds.resolve(guild)?.commands.cache : this.client.application?.commands.cache;
|
|
110
110
|
if (!commands)
|
|
111
111
|
throw new Error('Guild not found in cache');
|
|
112
|
-
return commands.find(cmd => typeof command === 'string' ? cmd.id === command || cmd.name === command : cmd.name === command.name || (command instanceof discord_js_1.ApplicationCommand && cmd.id === command.id));
|
|
112
|
+
return commands.find(cmd => (typeof command === 'string' ? cmd.id === command || cmd.name === command : cmd.name === command.name || (command instanceof discord_js_1.ApplicationCommand && cmd.id === command.id)));
|
|
113
113
|
}
|
|
114
114
|
async fetch(commandId, guild) {
|
|
115
115
|
const manager = guild ? this.client.guilds.resolve(guild)?.commands : this.client.application?.commands;
|
|
@@ -122,9 +122,7 @@ class ApplicationCommandManager {
|
|
|
122
122
|
if (cmd?.toJSON === undefined)
|
|
123
123
|
return cmd;
|
|
124
124
|
if (SlashCommandBuilder_1.SlashCommandBuilder.isSlashCommandBuilder(cmd) && this.client.config.commands.slashCommand.setRequiredPermissions) {
|
|
125
|
-
const permissions = setPermissions || this.client.config.commands.slashCommand.permissions.enabled
|
|
126
|
-
? this.client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions
|
|
127
|
-
: undefined;
|
|
125
|
+
const permissions = setPermissions || this.client.config.commands.slashCommand.permissions.enabled ? this.client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions : undefined;
|
|
128
126
|
if (permissions) {
|
|
129
127
|
cmd.setRequiredMemberPermissions(...permissions);
|
|
130
128
|
if (!this.client.isClientLogsSilent)
|
|
@@ -23,10 +23,10 @@ class ClientCommandManager {
|
|
|
23
23
|
*/
|
|
24
24
|
add(...commands) {
|
|
25
25
|
for (const command of (0, discord_js_1.normalizeArray)(commands)) {
|
|
26
|
-
if (command.type === builders_1.
|
|
26
|
+
if (command.type === builders_1.CommandType.SlashCommand) {
|
|
27
27
|
this.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
|
|
28
28
|
}
|
|
29
|
-
else if (command.type === builders_1.
|
|
29
|
+
else if (command.type === builders_1.CommandType.MessageCommand) {
|
|
30
30
|
this.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -37,11 +37,10 @@ class ClientCommandManager {
|
|
|
37
37
|
}
|
|
38
38
|
get(command, type) {
|
|
39
39
|
switch (type) {
|
|
40
|
-
case builders_1.
|
|
40
|
+
case builders_1.CommandType.SlashCommand:
|
|
41
41
|
return this.slashCommands.get(command);
|
|
42
|
-
case builders_1.
|
|
43
|
-
return
|
|
44
|
-
(this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined));
|
|
42
|
+
case builders_1.CommandType.MessageCommand:
|
|
43
|
+
return this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined);
|
|
45
44
|
default:
|
|
46
45
|
throw new TypeError('Unknown command type');
|
|
47
46
|
}
|
|
@@ -40,13 +40,13 @@ class ClientModuleManager {
|
|
|
40
40
|
this.client = options.client;
|
|
41
41
|
options.modules?.forEach(m => (m instanceof RecipleModule_1.RecipleModule ? m : new RecipleModule_1.RecipleModule({ client: this.client, script: m })));
|
|
42
42
|
}
|
|
43
|
-
async startModules(modules,
|
|
43
|
+
async startModules(modules, ignoreErrors = true) {
|
|
44
44
|
for (const module_ of modules) {
|
|
45
45
|
if (!this.client.isClientLogsSilent)
|
|
46
46
|
this.client.logger.log(`Starting module '${module_}'`);
|
|
47
47
|
try {
|
|
48
48
|
let error;
|
|
49
|
-
const start = await module_.start(
|
|
49
|
+
const start = await module_.start().catch(err => {
|
|
50
50
|
error = err;
|
|
51
51
|
return false;
|
|
52
52
|
});
|
|
@@ -58,9 +58,6 @@ class ClientModuleManager {
|
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
60
|
this.modules.set(module_.id, module_);
|
|
61
|
-
if (addModuleCommandsToClient) {
|
|
62
|
-
this.client.commands.add(module_.commands.toJSON());
|
|
63
|
-
}
|
|
64
61
|
}
|
|
65
62
|
catch (err) {
|
|
66
63
|
if (!ignoreErrors)
|
|
@@ -71,7 +68,7 @@ class ClientModuleManager {
|
|
|
71
68
|
}
|
|
72
69
|
return modules;
|
|
73
70
|
}
|
|
74
|
-
async loadModules(modules, ignoreErrors = true) {
|
|
71
|
+
async loadModules(modules, addModuleCommandsToClient = true, ignoreErrors = true) {
|
|
75
72
|
for (const module_ of this.modules.toJSON()) {
|
|
76
73
|
try {
|
|
77
74
|
await module_.load().catch(err => {
|
|
@@ -79,6 +76,9 @@ class ClientModuleManager {
|
|
|
79
76
|
});
|
|
80
77
|
if (!this.client.isClientLogsSilent)
|
|
81
78
|
this.client.logger.log(`Loaded module '${module_}'`);
|
|
79
|
+
if (addModuleCommandsToClient) {
|
|
80
|
+
this.client.commands.add(module_.commands.toJSON());
|
|
81
|
+
}
|
|
82
82
|
}
|
|
83
83
|
catch (err) {
|
|
84
84
|
if (!ignoreErrors)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CommandType = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Types of command builders
|
|
6
6
|
*/
|
|
7
|
-
var
|
|
8
|
-
(function (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})(
|
|
7
|
+
var CommandType;
|
|
8
|
+
(function (CommandType) {
|
|
9
|
+
CommandType[CommandType["MessageCommand"] = 0] = "MessageCommand";
|
|
10
|
+
CommandType[CommandType["SlashCommand"] = 1] = "SlashCommand";
|
|
11
|
+
})(CommandType = exports.CommandType || (exports.CommandType = {}));
|
package/dist/cjs/reciple/util.js
CHANGED
|
@@ -31,7 +31,7 @@ exports.deprecationWarning = deprecationWarning;
|
|
|
31
31
|
function validateCommandBuilder(command) {
|
|
32
32
|
if (!command.name)
|
|
33
33
|
return false;
|
|
34
|
-
if (command.type === builders_1.
|
|
34
|
+
if (command.type === builders_1.CommandType.MessageCommand && command.options.length && command.options.some(o => !o.name))
|
|
35
35
|
return false;
|
|
36
36
|
return true;
|
|
37
37
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ export * from './reciple/classes/builders/MessageCommandBuilder';
|
|
|
2
2
|
export * from './reciple/classes/builders/MessageCommandOptionBuilder';
|
|
3
3
|
export * from './reciple/classes/builders/SlashCommandBuilder';
|
|
4
4
|
export * from './reciple/classes/managers/ApplicationCommandManager';
|
|
5
|
-
export * from './reciple/classes/managers/CommandCooldownManager';
|
|
6
5
|
export * from './reciple/classes/managers/ClientCommandManager';
|
|
7
6
|
export * from './reciple/classes/managers/ClientModuleManager';
|
|
7
|
+
export * from './reciple/classes/managers/CommandCooldownManager';
|
|
8
8
|
export * from './reciple/classes/managers/MessageCommandOptionManager';
|
|
9
9
|
export * from './reciple/classes/RecipleClient';
|
|
10
10
|
export * from './reciple/classes/RecipleConfig';
|
|
@@ -45,8 +45,8 @@ export declare class RecipleModule<M = unknown> {
|
|
|
45
45
|
metadata?: M;
|
|
46
46
|
get displayName(): string;
|
|
47
47
|
constructor(options: RecipleModuleOptions<M>);
|
|
48
|
-
start(
|
|
49
|
-
load(): Promise<void>;
|
|
48
|
+
start(): Promise<boolean>;
|
|
49
|
+
load(resolveCommands?: boolean): Promise<void>;
|
|
50
50
|
unLoad(reason?: any): Promise<void>;
|
|
51
51
|
registerSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
|
|
52
52
|
unregisterSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
|
|
2
2
|
import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
|
|
3
3
|
import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
|
|
4
4
|
import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
|
|
@@ -53,20 +53,20 @@ export interface MessageCommandValidatedOption {
|
|
|
53
53
|
/**
|
|
54
54
|
* Halt data for message command
|
|
55
55
|
*/
|
|
56
|
-
export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<
|
|
56
|
+
export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<CommandType.MessageCommand, T>;
|
|
57
57
|
/**
|
|
58
58
|
* Message command halt function
|
|
59
59
|
*/
|
|
60
|
-
export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<
|
|
60
|
+
export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandType.MessageCommand, T>;
|
|
61
61
|
/**
|
|
62
62
|
* Message command execute function
|
|
63
63
|
*/
|
|
64
|
-
export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<
|
|
64
|
+
export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.MessageCommand, T>;
|
|
65
65
|
/**
|
|
66
66
|
* Reciple builder for message command
|
|
67
67
|
*/
|
|
68
68
|
export declare class MessageCommandBuilder<T = unknown> implements SharedCommandBuilderProperties<T> {
|
|
69
|
-
readonly type =
|
|
69
|
+
readonly type = CommandType.MessageCommand;
|
|
70
70
|
name: string;
|
|
71
71
|
description: string;
|
|
72
72
|
cooldown: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, AnySlashCommandBuilder, SlashCommandData, AnySlashCommandOptionData, AnySlashCommandOptionBuilder } from '../../types/builders';
|
|
2
2
|
import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
|
|
3
3
|
import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, SlashCommandRoleOption, SlashCommandAttachmentOption, SlashCommandMentionableOption, SlashCommandStringOption, SlashCommandIntegerOption, SlashCommandNumberOption, SharedSlashCommandOptions } from 'discord.js';
|
|
4
4
|
/**
|
|
@@ -17,15 +17,15 @@ export interface SlashCommandExecuteData<T = unknown> extends BaseCommandExecute
|
|
|
17
17
|
/**
|
|
18
18
|
* Slash command halt data
|
|
19
19
|
*/
|
|
20
|
-
export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<
|
|
20
|
+
export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandType.SlashCommand, T>;
|
|
21
21
|
/**
|
|
22
22
|
* Slash command halt function
|
|
23
23
|
*/
|
|
24
|
-
export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<
|
|
24
|
+
export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandType.SlashCommand, T>;
|
|
25
25
|
/**
|
|
26
26
|
* Slash command execute function
|
|
27
27
|
*/
|
|
28
|
-
export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<
|
|
28
|
+
export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.SlashCommand, T>;
|
|
29
29
|
export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addBooleanOption' | 'addUserOption' | 'addChannelOption' | 'addRoleOption' | 'addAttachmentOption' | 'addMentionableOption' | 'addStringOption' | 'addIntegerOption' | 'addNumberOption'>;
|
|
30
30
|
export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addSubcommand' | 'addSubcommandGroup'>;
|
|
31
31
|
export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
|
|
@@ -45,7 +45,7 @@ export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandB
|
|
|
45
45
|
* Reciple builder for slash command
|
|
46
46
|
*/
|
|
47
47
|
export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
|
|
48
|
-
readonly type =
|
|
48
|
+
readonly type = CommandType.SlashCommand;
|
|
49
49
|
cooldown: number;
|
|
50
50
|
requiredBotPermissions: PermissionResolvable[];
|
|
51
51
|
requiredMemberPermissions: PermissionResolvable[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApplicationCommandData, Collection, GuildResolvable, RestOrArray } from 'discord.js';
|
|
2
|
-
import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder,
|
|
2
|
+
import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandType, MessageCommandData, SlashCommandData } from '../../types/builders';
|
|
3
3
|
import { MessageCommandBuilder } from '../builders/MessageCommandBuilder';
|
|
4
4
|
import { SlashCommandBuilder } from '../builders/SlashCommandBuilder';
|
|
5
5
|
import { RecipleClient } from '../RecipleClient';
|
|
@@ -27,8 +27,8 @@ export declare class ClientCommandManager {
|
|
|
27
27
|
* @param type Command type
|
|
28
28
|
*/
|
|
29
29
|
get(command: string, type?: undefined): AnyCommandBuilder | undefined;
|
|
30
|
-
get(command: string, type?:
|
|
31
|
-
get(command: string, type?:
|
|
30
|
+
get(command: string, type?: CommandType.MessageCommand): MessageCommandBuilder | undefined;
|
|
31
|
+
get(command: string, type?: CommandType.SlashCommand): SlashCommandBuilder | undefined;
|
|
32
32
|
/**
|
|
33
33
|
* Register application commands
|
|
34
34
|
* @param guilds Register application commands to guilds
|
|
@@ -10,8 +10,8 @@ export declare class ClientModuleManager {
|
|
|
10
10
|
readonly client: RecipleClient;
|
|
11
11
|
readonly modules: Collection<string, RecipleModule>;
|
|
12
12
|
constructor(options: ClientModuleManagerOptions);
|
|
13
|
-
startModules(modules: RecipleModule[],
|
|
14
|
-
loadModules(modules: RecipleModule[], ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
13
|
+
startModules(modules: RecipleModule[], ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
14
|
+
loadModules(modules: RecipleModule[], addModuleCommandsToClient?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
15
15
|
unLoadModules(modules: RecipleModule[], removeUnloadedModules?: boolean, ignoreErrors?: boolean): Promise<RecipleModule[]>;
|
|
16
16
|
getModulesFromFiles(options: ClientModuleManagerGetModulesFromFilesOptions): Promise<RecipleModule[]>;
|
|
17
17
|
static validateScript(script: unknown): script is RecipleScript;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Guild, RestOrArray, TextBasedChannel, User } from 'discord.js';
|
|
2
|
-
import {
|
|
2
|
+
import { CommandType } from '../../types/builders';
|
|
3
3
|
/**
|
|
4
4
|
* cooled-down user object interface
|
|
5
5
|
*/
|
|
@@ -15,7 +15,7 @@ export interface CooledDownUser {
|
|
|
15
15
|
/**
|
|
16
16
|
* Command type
|
|
17
17
|
*/
|
|
18
|
-
type:
|
|
18
|
+
type: CommandType;
|
|
19
19
|
/**
|
|
20
20
|
* In guild
|
|
21
21
|
*/
|
|
@@ -25,11 +25,11 @@ export declare type AnyCommandExecuteFunction<T = unknown> = SlashCommandExecute
|
|
|
25
25
|
/**
|
|
26
26
|
* Command halt function
|
|
27
27
|
*/
|
|
28
|
-
export declare type CommandHaltFunction<T extends
|
|
28
|
+
export declare type CommandHaltFunction<T extends CommandType, M = unknown> = (haltData: T extends CommandType.SlashCommand ? SlashCommandHaltData<M> : T extends CommandType.MessageCommand ? MessageCommandHaltData<M> : SlashCommandHaltData<M> | MessageCommandHaltData<M>) => Awaitable<boolean | null | undefined | void>;
|
|
29
29
|
/**
|
|
30
30
|
* Command execute function
|
|
31
31
|
*/
|
|
32
|
-
export declare type CommandExecuteFunction<T extends
|
|
32
|
+
export declare type CommandExecuteFunction<T extends CommandType, M = unknown> = (executeData: T extends CommandType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandType.MessageCommand ? MessageCommandExecuteData<M> : SlashCommandExecuteData<M> | MessageCommandExecuteData<M>) => Awaitable<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Message command options resolvable
|
|
35
35
|
*/
|
|
@@ -53,7 +53,7 @@ export declare type AnySlashCommandOptionsOnlyOptionBuilder = SlashCommandAttach
|
|
|
53
53
|
/**
|
|
54
54
|
* Types of command builders
|
|
55
55
|
*/
|
|
56
|
-
export declare enum
|
|
56
|
+
export declare enum CommandType {
|
|
57
57
|
MessageCommand = 0,
|
|
58
58
|
SlashCommand = 1
|
|
59
59
|
}
|
|
@@ -61,7 +61,7 @@ export declare enum CommandBuilderType {
|
|
|
61
61
|
* Shared command builder methods and properties
|
|
62
62
|
*/
|
|
63
63
|
export interface SharedCommandBuilderProperties<T = unknown> {
|
|
64
|
-
readonly type:
|
|
64
|
+
readonly type: CommandType;
|
|
65
65
|
cooldown: number;
|
|
66
66
|
requiredBotPermissions: PermissionResolvable[];
|
|
67
67
|
requiredMemberPermissions: PermissionResolvable[];
|
|
@@ -111,7 +111,7 @@ export interface SharedCommandDataProperties {
|
|
|
111
111
|
* Slash command object data interface
|
|
112
112
|
*/
|
|
113
113
|
export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
|
|
114
|
-
type:
|
|
114
|
+
type: CommandType.SlashCommand;
|
|
115
115
|
nameLocalizations?: LocalizationMap;
|
|
116
116
|
descriptionLocalizations?: LocalizationMap;
|
|
117
117
|
options?: (AnySlashCommandOptionData | AnySlashCommandOptionBuilder)[];
|
|
@@ -179,7 +179,7 @@ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProper
|
|
|
179
179
|
* Message command object data interface
|
|
180
180
|
*/
|
|
181
181
|
export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
|
|
182
|
-
type:
|
|
182
|
+
type: CommandType.MessageCommand;
|
|
183
183
|
aliases?: string[];
|
|
184
184
|
validateOptions?: boolean;
|
|
185
185
|
allowExecuteInDM?: boolean;
|
|
@@ -3,7 +3,7 @@ import { SlashCommandExecuteData, SlashCommandHaltData } from '../classes/builde
|
|
|
3
3
|
import { MessageCommandOptionManager } from '../classes/managers/MessageCommandOptionManager';
|
|
4
4
|
import { CooledDownUser } from '../classes/managers/CommandCooldownManager';
|
|
5
5
|
import { RecipleClient } from '../classes/RecipleClient';
|
|
6
|
-
import {
|
|
6
|
+
import { CommandType } from '../types/builders';
|
|
7
7
|
/**
|
|
8
8
|
* Any command halt data
|
|
9
9
|
*/
|
|
@@ -11,7 +11,7 @@ export declare type AnyCommandHaltData<T = unknown> = SlashCommandHaltData<T> |
|
|
|
11
11
|
/**
|
|
12
12
|
* command halt data
|
|
13
13
|
*/
|
|
14
|
-
export declare type CommandHaltData<T extends
|
|
14
|
+
export declare type CommandHaltData<T extends CommandType, M = unknown> = CommandErrorData<T, M> | CommandCooldownData<T, M> | (T extends CommandType.SlashCommand ? never : CommandInvalidArguments<T, M> | CommandMissingArguments<T, M>) | CommandMissingMemberPermissions<T, M> | CommandMissingBotPermissions<T, M>;
|
|
15
15
|
/**
|
|
16
16
|
* Any command execute data
|
|
17
17
|
*/
|
|
@@ -28,7 +28,7 @@ export interface BaseCommandExecuteData {
|
|
|
28
28
|
/**
|
|
29
29
|
* Command halt reason base
|
|
30
30
|
*/
|
|
31
|
-
export interface BaseCommandHaltData<T extends
|
|
31
|
+
export interface BaseCommandHaltData<T extends CommandType, M = unknown> {
|
|
32
32
|
/**
|
|
33
33
|
* Halt reason
|
|
34
34
|
*/
|
|
@@ -36,36 +36,36 @@ export interface BaseCommandHaltData<T extends CommandBuilderType, M = unknown>
|
|
|
36
36
|
/**
|
|
37
37
|
* Command execute da6a
|
|
38
38
|
*/
|
|
39
|
-
executeData: T extends
|
|
39
|
+
executeData: T extends CommandType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandType.MessageCommand ? MessageCommandExecuteData<M> : AnyCommandExecuteData<M>;
|
|
40
40
|
}
|
|
41
|
-
export interface CommandErrorData<T extends
|
|
41
|
+
export interface CommandErrorData<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
42
42
|
reason: CommandHaltReason.Error;
|
|
43
43
|
/**
|
|
44
44
|
* Caught error
|
|
45
45
|
*/
|
|
46
46
|
error: any;
|
|
47
47
|
}
|
|
48
|
-
export interface CommandCooldownData<T extends
|
|
48
|
+
export interface CommandCooldownData<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M>, CooledDownUser {
|
|
49
49
|
reason: CommandHaltReason.Cooldown;
|
|
50
50
|
}
|
|
51
|
-
export interface CommandInvalidArguments<T extends
|
|
51
|
+
export interface CommandInvalidArguments<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
52
52
|
reason: CommandHaltReason.InvalidArguments;
|
|
53
53
|
/**
|
|
54
54
|
* Arguments that are invalid
|
|
55
55
|
*/
|
|
56
56
|
invalidArguments: MessageCommandOptionManager;
|
|
57
57
|
}
|
|
58
|
-
export interface CommandMissingArguments<T extends
|
|
58
|
+
export interface CommandMissingArguments<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
59
59
|
reason: CommandHaltReason.MissingArguments;
|
|
60
60
|
/**
|
|
61
61
|
* Arguments that are missing
|
|
62
62
|
*/
|
|
63
63
|
missingArguments: MessageCommandOptionManager;
|
|
64
64
|
}
|
|
65
|
-
export interface CommandMissingMemberPermissions<T extends
|
|
65
|
+
export interface CommandMissingMemberPermissions<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
66
66
|
reason: CommandHaltReason.MissingMemberPermissions;
|
|
67
67
|
}
|
|
68
|
-
export interface CommandMissingBotPermissions<T extends
|
|
68
|
+
export interface CommandMissingBotPermissions<T extends CommandType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
69
69
|
reason: CommandHaltReason.MissingBotPermissions;
|
|
70
70
|
}
|
|
71
71
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.9",
|
|
4
4
|
"bin": "./dist/cjs/bin.js",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
"url": "https://github.com/FalloutStudios/reciple/issues"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"format": "
|
|
30
|
-
"clean": "
|
|
31
|
-
"build": "
|
|
32
|
-
"build:publish": "
|
|
33
|
-
"build:publish-dev": "
|
|
34
|
-
"test": "
|
|
35
|
-
"docs": "
|
|
36
|
-
"watch": "
|
|
29
|
+
"format": "npx prettier --write src",
|
|
30
|
+
"clean": "npx rimraf dist",
|
|
31
|
+
"build": "npm run clean && npx tsc",
|
|
32
|
+
"build:publish": "npm run format && npm run build && npx docs && npm publish",
|
|
33
|
+
"build:publish-dev": "npm run format && npm run build && npm publish --tag dev",
|
|
34
|
+
"test": "npm run build && npm run start -w test",
|
|
35
|
+
"docs": "npx docgen --typescript true -c ./docs/index.json -o ./docs/docs.json -i src/index.ts",
|
|
36
|
+
"watch": "npx tsc --watch --noEmit",
|
|
37
|
+
"husky:install": "npx husky install"
|
|
37
38
|
},
|
|
38
39
|
"repository": {
|
|
39
40
|
"type": "git",
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
"@types/node": "^18.11.0",
|
|
64
65
|
"@types/semver": "^7.3.12",
|
|
65
66
|
"discord.js": "^14.6.0",
|
|
67
|
+
"husky": "^8.0.1",
|
|
66
68
|
"prettier": "2.7.1",
|
|
67
69
|
"rimraf": "^3.0.2",
|
|
68
70
|
"typescript": "^4.8.4"
|
|
@@ -72,6 +74,5 @@
|
|
|
72
74
|
},
|
|
73
75
|
"workspaces": [
|
|
74
76
|
"test"
|
|
75
|
-
]
|
|
76
|
-
|
|
77
|
-
}
|
|
77
|
+
]
|
|
78
|
+
}
|
package/docs/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# [VIEW DOCS](https://reciple.js.org/#/docs)
|