reciple 4.0.0-pre.1 → 4.0.0-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 +7 -7
- package/bin/index.d.ts +1 -1
- package/bin/index.js +1 -1
- package/bin/reciple/classes/CommandCooldownManager.d.ts +2 -2
- package/bin/reciple/classes/RecipleClient.d.ts +6 -6
- package/bin/reciple/classes/RecipleClient.js +22 -22
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +5 -5
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +1 -1
- package/bin/reciple/classes/builders/SlashCommandBuilder.d.ts +5 -5
- package/bin/reciple/classes/builders/SlashCommandBuilder.js +1 -1
- package/bin/reciple/logger.d.ts +0 -8
- package/bin/reciple/logger.js +1 -14
- package/bin/reciple/modules.d.ts +4 -4
- package/bin/reciple/modules.js +2 -2
- package/bin/reciple/permissions.d.ts +2 -2
- package/bin/reciple/registerInteractionCommands.d.ts +2 -2
- package/bin/reciple/types/builders.d.ts +3 -3
- package/bin/reciple/types/builders.js +6 -6
- package/bin/reciple/types/commands.d.ts +16 -16
- package/bin/reciple/types/commands.js +10 -10
- package/bin/reciple/types/paramOptions.d.ts +5 -5
- package/package.json +3 -2
package/bin/bin.js
CHANGED
|
@@ -12,7 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
|
-
var _a, _b;
|
|
15
|
+
var _a, _b, _c;
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const RecipleClient_1 = require("./reciple/classes/RecipleClient");
|
|
18
18
|
const RecipleConfig_1 = require("./reciple/classes/RecipleConfig");
|
|
@@ -26,15 +26,15 @@ if (flags_1.flags.version) {
|
|
|
26
26
|
console.log(`v${version_1.version}`);
|
|
27
27
|
process.exit(0);
|
|
28
28
|
}
|
|
29
|
-
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'
|
|
30
|
-
if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)('./reciple.yml')) {
|
|
31
|
-
const ask = (
|
|
29
|
+
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
|
|
30
|
+
if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)((_a = flags_1.flags.config) !== null && _a !== void 0 ? _a : './reciple.yml')) {
|
|
31
|
+
const ask = (_b = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ')) !== null && _b !== void 0 ? _b : '';
|
|
32
32
|
if (ask.toString().toLowerCase() !== 'y')
|
|
33
33
|
process.exit(0);
|
|
34
34
|
}
|
|
35
35
|
let configParser;
|
|
36
36
|
try {
|
|
37
|
-
configParser = new RecipleConfig_1.RecipleConfig((
|
|
37
|
+
configParser = new RecipleConfig_1.RecipleConfig((_c = flags_1.flags.config) !== null && _c !== void 0 ? _c : './reciple.yml').parseConfig();
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
40
|
console.error(`${chalk_1.default.bold.red('Config Error')}: ${chalk_1.default.white(err.message)}`);
|
|
@@ -47,9 +47,9 @@ if (config.fileLogging.clientLogs)
|
|
|
47
47
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
48
|
yield client.startModules();
|
|
49
49
|
client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
var
|
|
50
|
+
var _d;
|
|
51
51
|
if (client.isClientLogsEnabled())
|
|
52
|
-
client.logger.warn(`Logged in as ${((
|
|
52
|
+
client.logger.warn(`Logged in as ${((_d = client.user) === null || _d === void 0 ? void 0 : _d.tag) || 'Unknown'}!`);
|
|
53
53
|
yield client.loadModules();
|
|
54
54
|
client.addCommandListeners();
|
|
55
55
|
}));
|
package/bin/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ export * from './reciple/classes/CommandCooldownManager';
|
|
|
2
2
|
export * from './reciple/classes/MessageCommandOptionManager';
|
|
3
3
|
export * from './reciple/classes/RecipleClient';
|
|
4
4
|
export * from './reciple/classes/RecipleConfig';
|
|
5
|
-
export * from './reciple/classes/builders/SlashCommandBuilder';
|
|
6
5
|
export * from './reciple/classes/builders/MessageCommandBuilder';
|
|
7
6
|
export * from './reciple/classes/builders/MessageCommandOptionBuilder';
|
|
7
|
+
export * from './reciple/classes/builders/SlashCommandBuilder';
|
|
8
8
|
export * from './reciple/types/builders';
|
|
9
9
|
export * from './reciple/types/commands';
|
|
10
10
|
export * from './reciple/types/paramOptions';
|
package/bin/index.js
CHANGED
|
@@ -18,9 +18,9 @@ __exportStar(require("./reciple/classes/CommandCooldownManager"), exports);
|
|
|
18
18
|
__exportStar(require("./reciple/classes/MessageCommandOptionManager"), exports);
|
|
19
19
|
__exportStar(require("./reciple/classes/RecipleClient"), exports);
|
|
20
20
|
__exportStar(require("./reciple/classes/RecipleConfig"), exports);
|
|
21
|
-
__exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports);
|
|
22
21
|
__exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
|
|
23
22
|
__exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
|
|
23
|
+
__exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports);
|
|
24
24
|
__exportStar(require("./reciple/types/builders"), exports);
|
|
25
25
|
__exportStar(require("./reciple/types/commands"), exports);
|
|
26
26
|
__exportStar(require("./reciple/types/paramOptions"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandBuilderType } from '../types/builders';
|
|
2
2
|
import { Guild, TextBasedChannel, User } from 'discord.js';
|
|
3
3
|
/**
|
|
4
4
|
* Object interface for cooled-down user
|
|
@@ -6,7 +6,7 @@ import { Guild, TextBasedChannel, User } from 'discord.js';
|
|
|
6
6
|
export interface CooledDownUser {
|
|
7
7
|
user: User;
|
|
8
8
|
command: string;
|
|
9
|
-
type:
|
|
9
|
+
type: CommandBuilderType;
|
|
10
10
|
guild?: Guild | null;
|
|
11
11
|
channel?: TextBasedChannel;
|
|
12
12
|
expireTime: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RecipleModule } from '../modules';
|
|
2
2
|
import { ApplicationCommandBuilder } from '../registerInteractionCommands';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { CommandBuilder, CommandBuilderType } from '../types/builders';
|
|
4
|
+
import { RecipleClientAddModuleOptions } from '../types/paramOptions';
|
|
5
5
|
import { MessageCommandBuilder, MessageCommandExecuteData } from './builders/MessageCommandBuilder';
|
|
6
6
|
import { SlashCommandBuilder, SlashCommandExecuteData } from './builders/SlashCommandBuilder';
|
|
7
7
|
import { CommandCooldownManager } from './CommandCooldownManager';
|
|
@@ -77,12 +77,12 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
77
77
|
* Add module
|
|
78
78
|
* @param options Module options
|
|
79
79
|
*/
|
|
80
|
-
addModule(options:
|
|
80
|
+
addModule(options: RecipleClientAddModuleOptions): Promise<void>;
|
|
81
81
|
/**
|
|
82
82
|
* Add slash or message command to client
|
|
83
83
|
* @param command Slash/Message command builder
|
|
84
84
|
*/
|
|
85
|
-
addCommand(command:
|
|
85
|
+
addCommand(command: CommandBuilder): RecipleClient<Ready>;
|
|
86
86
|
/**
|
|
87
87
|
* Listed to command executions
|
|
88
88
|
*/
|
|
@@ -109,8 +109,8 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
109
109
|
* @param command Command name
|
|
110
110
|
* @param type Command type
|
|
111
111
|
*/
|
|
112
|
-
findCommand(command: string, type:
|
|
113
|
-
findCommand(command: string, type:
|
|
112
|
+
findCommand(command: string, type: CommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
|
|
113
|
+
findCommand(command: string, type: CommandBuilderType.SlashCommand): SlashCommandBuilder | undefined;
|
|
114
114
|
/**
|
|
115
115
|
* Returns true if client logs is enabled
|
|
116
116
|
*/
|
|
@@ -138,10 +138,10 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
138
138
|
*/
|
|
139
139
|
addCommand(command) {
|
|
140
140
|
var _a;
|
|
141
|
-
if (command.builder === builders_1.
|
|
141
|
+
if (command.builder === builders_1.CommandBuilderType.MessageCommand) {
|
|
142
142
|
this.commands.messageCommands[command.name] = command;
|
|
143
143
|
}
|
|
144
|
-
else if (command.builder === builders_1.
|
|
144
|
+
else if (command.builder === builders_1.CommandBuilderType.SlashCommand) {
|
|
145
145
|
this.commands.slashCommands[command.name] = command;
|
|
146
146
|
}
|
|
147
147
|
else if (this.isClientLogsEnabled()) {
|
|
@@ -172,7 +172,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
172
172
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.commands.messageCommand.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
|
|
173
173
|
if (!parseCommand || !(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command))
|
|
174
174
|
return;
|
|
175
|
-
const command = this.findCommand(parseCommand.command, builders_1.
|
|
175
|
+
const command = this.findCommand(parseCommand.command, builders_1.CommandBuilderType.MessageCommand);
|
|
176
176
|
if (!command)
|
|
177
177
|
return;
|
|
178
178
|
const commandOptions = (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
|
|
@@ -195,20 +195,20 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
195
195
|
return;
|
|
196
196
|
if (command.validateOptions) {
|
|
197
197
|
if (commandOptions.some(o => o.invalid)) {
|
|
198
|
-
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
198
|
+
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.invalid)) }))) {
|
|
199
199
|
message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this._replyError(er));
|
|
200
200
|
}
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
if (commandOptions.some(o => o.missing)) {
|
|
204
|
-
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
204
|
+
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.missing)) }))) {
|
|
205
205
|
message.reply(this.getMessage('missingArguments', 'Not enough arguments.')).catch(er => this._replyError(er));
|
|
206
206
|
}
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
if (message.guild && !(0, permissions_1.botHasExecutePermissions)(message.guild, command.requiredBotPermissions)) {
|
|
211
|
-
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
211
|
+
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingBotPermissions }))) {
|
|
212
212
|
message.reply(this.getMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
|
|
213
213
|
}
|
|
214
214
|
return;
|
|
@@ -218,13 +218,13 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
218
218
|
command: command.name,
|
|
219
219
|
channel: message.channel,
|
|
220
220
|
guild: message.guild,
|
|
221
|
-
type: builders_1.
|
|
221
|
+
type: builders_1.CommandBuilderType.MessageCommand
|
|
222
222
|
};
|
|
223
223
|
if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
|
|
224
224
|
this.commandCooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
|
|
225
225
|
}
|
|
226
226
|
else if (this.config.commands.messageCommand.enableCooldown && command.cooldown) {
|
|
227
|
-
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.
|
|
227
|
+
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.HaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
|
|
228
228
|
yield message.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
|
|
229
229
|
}
|
|
230
230
|
return;
|
|
@@ -232,16 +232,16 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
232
232
|
try {
|
|
233
233
|
yield Promise.resolve(command.execute(executeData))
|
|
234
234
|
.then(() => this.emit('recipleMessageCommandCreate', executeData))
|
|
235
|
-
.catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
235
|
+
.catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
|
|
236
236
|
return executeData;
|
|
237
237
|
}
|
|
238
238
|
catch (err) {
|
|
239
|
-
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
239
|
+
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err }))) {
|
|
240
240
|
this._commandExecuteError(err, executeData);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
244
|
+
else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingMemberPermissions }))) {
|
|
245
245
|
message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
|
|
246
246
|
}
|
|
247
247
|
});
|
|
@@ -255,7 +255,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
255
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
256
|
if (!interaction || interaction.type !== discord_js_1.InteractionType.ApplicationCommand || !interaction.isChatInputCommand() || !this.isReady())
|
|
257
257
|
return;
|
|
258
|
-
const command = this.findCommand(interaction.commandName, builders_1.
|
|
258
|
+
const command = this.findCommand(interaction.commandName, builders_1.CommandBuilderType.SlashCommand);
|
|
259
259
|
if (!command)
|
|
260
260
|
return;
|
|
261
261
|
const executeData = {
|
|
@@ -271,7 +271,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
271
271
|
if (!command || (0, permissions_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
|
|
272
272
|
return;
|
|
273
273
|
if (interaction.guild && !(0, permissions_1.botHasExecutePermissions)(interaction.guild, command.requiredBotPermissions)) {
|
|
274
|
-
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
274
|
+
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingBotPermissions }))) {
|
|
275
275
|
yield interaction.reply(this.getMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
|
|
276
276
|
}
|
|
277
277
|
return;
|
|
@@ -281,13 +281,13 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
281
281
|
command: command.name,
|
|
282
282
|
channel: (_b = interaction.channel) !== null && _b !== void 0 ? _b : undefined,
|
|
283
283
|
guild: interaction.guild,
|
|
284
|
-
type: builders_1.
|
|
284
|
+
type: builders_1.CommandBuilderType.SlashCommand
|
|
285
285
|
};
|
|
286
286
|
if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
|
|
287
287
|
this.commandCooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
|
|
288
288
|
}
|
|
289
289
|
else if (this.config.commands.slashCommand.enableCooldown && command.cooldown) {
|
|
290
|
-
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.
|
|
290
|
+
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.HaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
|
|
291
291
|
yield interaction.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
|
|
292
292
|
}
|
|
293
293
|
return;
|
|
@@ -295,16 +295,16 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
295
295
|
try {
|
|
296
296
|
yield Promise.resolve(command.execute(executeData))
|
|
297
297
|
.then(() => this.emit('recipleInteractionCommandCreate', executeData))
|
|
298
|
-
.catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
298
|
+
.catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
|
|
299
299
|
return executeData;
|
|
300
300
|
}
|
|
301
301
|
catch (err) {
|
|
302
|
-
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
302
|
+
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err }))) {
|
|
303
303
|
this._commandExecuteError(err, executeData);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.
|
|
307
|
+
else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingMemberPermissions }))) {
|
|
308
308
|
yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
|
|
309
309
|
}
|
|
310
310
|
});
|
|
@@ -321,9 +321,9 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
321
321
|
findCommand(command, type) {
|
|
322
322
|
var _a;
|
|
323
323
|
switch (type) {
|
|
324
|
-
case builders_1.
|
|
324
|
+
case builders_1.CommandBuilderType.SlashCommand:
|
|
325
325
|
return this.commands.slashCommands[command];
|
|
326
|
-
case builders_1.
|
|
326
|
+
case builders_1.CommandBuilderType.MessageCommand:
|
|
327
327
|
return (_a = this.commands.messageCommands[command.toLowerCase()]) !== null && _a !== void 0 ? _a : (this.config.commands.messageCommand.allowCommandAlias
|
|
328
328
|
? Object.values(this.commands.messageCommands).find(c => c.aliases.some(a => a == (command === null || command === void 0 ? void 0 : command.toLowerCase())))
|
|
329
329
|
: undefined);
|
|
@@ -349,7 +349,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
349
349
|
return __awaiter(this, void 0, void 0, function* () {
|
|
350
350
|
try {
|
|
351
351
|
return (_a = (command.halt
|
|
352
|
-
? yield (command.builder == builders_1.
|
|
352
|
+
? yield (command.builder == builders_1.CommandBuilderType.SlashCommand
|
|
353
353
|
? Promise.resolve(command.halt(haltData))
|
|
354
354
|
: Promise.resolve(command.halt(haltData))).catch(err => { throw err; })
|
|
355
355
|
: false)) !== null && _a !== void 0 ? _a : false;
|
|
@@ -371,7 +371,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
371
371
|
_commandExecuteError(err, command) {
|
|
372
372
|
return __awaiter(this, void 0, void 0, function* () {
|
|
373
373
|
if (this.isClientLogsEnabled()) {
|
|
374
|
-
this.logger.error(`An error occured executing ${command.builder.builder == builders_1.
|
|
374
|
+
this.logger.error(`An error occured executing ${command.builder.builder == builders_1.CommandBuilderType.MessageCommand ? 'message' : 'slash'} command "${command.builder.name}"`);
|
|
375
375
|
this.logger.error(err);
|
|
376
376
|
}
|
|
377
377
|
if (!err || !command)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CommandBuilderType } from '../../types/builders';
|
|
2
|
+
import { HaltedCommandData } from '../../types/commands';
|
|
3
3
|
import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
|
|
4
4
|
import { RecipleClient } from '../RecipleClient';
|
|
5
5
|
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
@@ -29,7 +29,7 @@ export interface MessageCommandValidatedOption {
|
|
|
29
29
|
* Reciple builder for message command
|
|
30
30
|
*/
|
|
31
31
|
export declare class MessageCommandBuilder {
|
|
32
|
-
readonly builder =
|
|
32
|
+
readonly builder = CommandBuilderType.MessageCommand;
|
|
33
33
|
name: string;
|
|
34
34
|
cooldown: number;
|
|
35
35
|
description: string;
|
|
@@ -40,7 +40,7 @@ export declare class MessageCommandBuilder {
|
|
|
40
40
|
requiredMemberPermissions: PermissionResolvable[];
|
|
41
41
|
allowExecuteInDM: boolean;
|
|
42
42
|
allowExecuteByBots: boolean;
|
|
43
|
-
halt?: (haltData:
|
|
43
|
+
halt?: (haltData: HaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
|
|
44
44
|
execute: (executeData: MessageCommandExecuteData) => void;
|
|
45
45
|
/**
|
|
46
46
|
* Sets the command name
|
|
@@ -87,7 +87,7 @@ export declare class MessageCommandBuilder {
|
|
|
87
87
|
* Function when the command is interupted
|
|
88
88
|
* @param halt Function to execute when command is halted
|
|
89
89
|
*/
|
|
90
|
-
setHalt(halt?: (haltData:
|
|
90
|
+
setHalt(halt?: (haltData: HaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
|
|
91
91
|
/**
|
|
92
92
|
* Function when the command is executed
|
|
93
93
|
* @param execute Function to execute when the command is called
|
|
@@ -9,7 +9,7 @@ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
|
9
9
|
*/
|
|
10
10
|
class MessageCommandBuilder {
|
|
11
11
|
constructor() {
|
|
12
|
-
this.builder = builders_1.
|
|
12
|
+
this.builder = builders_1.CommandBuilderType.MessageCommand;
|
|
13
13
|
this.name = '';
|
|
14
14
|
this.cooldown = 0;
|
|
15
15
|
this.description = '';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CommandBuilderType } from '../../types/builders';
|
|
2
|
+
import { HaltedCommandData } from '../../types/commands';
|
|
3
3
|
import { RecipleClient } from '../RecipleClient';
|
|
4
4
|
import { Awaitable, ChatInputCommandInteraction, PermissionResolvable, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
|
|
5
5
|
/**
|
|
@@ -20,12 +20,12 @@ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
|
|
|
20
20
|
* Reciple builder for interaction/slash command
|
|
21
21
|
*/
|
|
22
22
|
export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
|
|
23
|
-
readonly builder =
|
|
23
|
+
readonly builder = CommandBuilderType.SlashCommand;
|
|
24
24
|
cooldown: number;
|
|
25
25
|
requiredBotPermissions: PermissionResolvable[];
|
|
26
26
|
requiredMemberPermissions: PermissionResolvable[];
|
|
27
27
|
allowExecuteInDM: boolean;
|
|
28
|
-
halt?: (haltData:
|
|
28
|
+
halt?: (haltData: HaltedCommandData<SlashCommandBuilder>) => Awaitable<boolean | void>;
|
|
29
29
|
execute: (executeData: SlashCommandExecuteData) => Awaitable<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Sets the execute cooldown for this command.
|
|
@@ -47,7 +47,7 @@ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
|
|
|
47
47
|
* Function when the command is interupted
|
|
48
48
|
* @param halt Function to execute when command is halted
|
|
49
49
|
*/
|
|
50
|
-
setHalt(halt?: (haltData:
|
|
50
|
+
setHalt(halt?: (haltData: HaltedCommandData<SlashCommandBuilder>) => Awaitable<boolean | void>): SlashCommandBuilder;
|
|
51
51
|
/**
|
|
52
52
|
* Function when the command is executed
|
|
53
53
|
* @param execute Function to execute when the command is called
|
|
@@ -9,7 +9,7 @@ const discord_js_1 = require("discord.js");
|
|
|
9
9
|
class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
|
-
this.builder = builders_1.
|
|
12
|
+
this.builder = builders_1.CommandBuilderType.SlashCommand;
|
|
13
13
|
this.cooldown = 0;
|
|
14
14
|
this.requiredBotPermissions = [];
|
|
15
15
|
this.requiredMemberPermissions = [];
|
package/bin/reciple/logger.d.ts
CHANGED
|
@@ -6,11 +6,3 @@ import { Logger } from 'fallout-utility';
|
|
|
6
6
|
* @param colorizeMessage add logger colours to messages
|
|
7
7
|
*/
|
|
8
8
|
export declare function createLogger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
|
|
9
|
-
/**
|
|
10
|
-
* Create new logger
|
|
11
|
-
* @deprecated Use `createLogger` instead
|
|
12
|
-
* @param stringifyJSON stringify json objects in console
|
|
13
|
-
* @param debugmode display debug messages
|
|
14
|
-
* @param colorizeMessage add logger colours to messages
|
|
15
|
-
*/
|
|
16
|
-
export declare function logger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
|
package/bin/reciple/logger.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createLogger = void 0;
|
|
7
7
|
const flags_1 = require("./flags");
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const fallout_utility_1 = require("fallout-utility");
|
|
@@ -34,16 +34,3 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
exports.createLogger = createLogger;
|
|
37
|
-
/**
|
|
38
|
-
* Create new logger
|
|
39
|
-
* @deprecated Use `createLogger` instead
|
|
40
|
-
* @param stringifyJSON stringify json objects in console
|
|
41
|
-
* @param debugmode display debug messages
|
|
42
|
-
* @param colorizeMessage add logger colours to messages
|
|
43
|
-
*/
|
|
44
|
-
// TODO: Remove this on next major release
|
|
45
|
-
function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
|
|
46
|
-
process.emitWarning('logger() is deprecated use createLogger() instead', 'DeprecationWarning');
|
|
47
|
-
return createLogger(stringifyJSON, debugmode, colorizeMessage);
|
|
48
|
-
}
|
|
49
|
-
exports.logger = logger;
|
package/bin/reciple/modules.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { RecipleClient } from './classes/RecipleClient';
|
|
2
|
-
import {
|
|
2
|
+
import { CommandBuilder } from './types/builders';
|
|
3
3
|
export declare type LoadedModules = {
|
|
4
|
-
commands:
|
|
4
|
+
commands: CommandBuilder[];
|
|
5
5
|
modules: RecipleModule[];
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Reciple script object interface
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export interface RecipleScript {
|
|
11
11
|
versions: string | string[];
|
|
12
|
-
commands?:
|
|
12
|
+
commands?: CommandBuilder[];
|
|
13
13
|
onLoad?(reciple: RecipleClient): void | Promise<void>;
|
|
14
14
|
onStart(reciple: RecipleClient): boolean | Promise<boolean>;
|
|
15
15
|
}
|
package/bin/reciple/modules.js
CHANGED
|
@@ -50,7 +50,7 @@ function loadModules(client, folder) {
|
|
|
50
50
|
throw new Error(script + ' onStart is not defined or returned false.');
|
|
51
51
|
if (module_.commands) {
|
|
52
52
|
for (const command of module_.commands) {
|
|
53
|
-
if (command.builder === builders_1.
|
|
53
|
+
if (command.builder === builders_1.CommandBuilderType.MessageCommand || command.builder === builders_1.CommandBuilderType.SlashCommand) {
|
|
54
54
|
commands.push(command);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -69,7 +69,7 @@ function loadModules(client, folder) {
|
|
|
69
69
|
client.logger.error(`A ${c.builder} command name is not defined in ${script}`);
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
|
-
if (c.builder === builders_1.
|
|
72
|
+
if (c.builder === builders_1.CommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
|
|
73
73
|
if (client.isClientLogsEnabled())
|
|
74
74
|
client.logger.error(`A ${c.builder} option name is not defined in ${script}`);
|
|
75
75
|
return false;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Config } from './classes/RecipleConfig';
|
|
2
|
-
import {
|
|
2
|
+
import { UserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
3
3
|
import { Guild, PermissionResolvable } from 'discord.js';
|
|
4
4
|
/**
|
|
5
5
|
* Check if the user has permissions to execute the given command name
|
|
6
6
|
* @param options options
|
|
7
7
|
*/
|
|
8
|
-
export declare function userHasCommandPermissions(options:
|
|
8
|
+
export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
|
|
9
9
|
/**
|
|
10
10
|
* Check if the bot has the required permissions in a guild
|
|
11
11
|
* @param guild Guild
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SlashCommandBuilder } from './classes/builders/SlashCommandBuilder';
|
|
2
|
-
import {
|
|
2
|
+
import { RegisterApplicationCommandsOptions } from './types/paramOptions';
|
|
3
3
|
import { ContextMenuCommandBuilder, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
|
|
4
4
|
export declare type ApplicationCommandBuilder = SlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
|
|
5
5
|
/**
|
|
6
6
|
* Register application commands
|
|
7
7
|
* @param options Register application commands options
|
|
8
8
|
*/
|
|
9
|
-
export declare function registerApplicationCommands(options:
|
|
9
|
+
export declare function registerApplicationCommands(options: RegisterApplicationCommandsOptions): Promise<void>;
|
|
@@ -3,15 +3,15 @@ import { SlashCommandBuilder, SlashCommandExecuteData } from '../classes/builder
|
|
|
3
3
|
/**
|
|
4
4
|
* Reciple command builders
|
|
5
5
|
*/
|
|
6
|
-
export declare type
|
|
6
|
+
export declare type CommandBuilder = MessageCommandBuilder | SlashCommandBuilder;
|
|
7
7
|
/**
|
|
8
8
|
* Reciple command builders execute data
|
|
9
9
|
*/
|
|
10
|
-
export declare type
|
|
10
|
+
export declare type CommandBuilderExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
|
|
11
11
|
/**
|
|
12
12
|
* Types of Reciple command builders
|
|
13
13
|
*/
|
|
14
|
-
export declare enum
|
|
14
|
+
export declare enum CommandBuilderType {
|
|
15
15
|
MessageCommand = 0,
|
|
16
16
|
SlashCommand = 1
|
|
17
17
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CommandBuilderType = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Types of Reciple command builders
|
|
6
6
|
*/
|
|
7
|
-
var
|
|
8
|
-
(function (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})(
|
|
7
|
+
var CommandBuilderType;
|
|
8
|
+
(function (CommandBuilderType) {
|
|
9
|
+
CommandBuilderType[CommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
|
|
10
|
+
CommandBuilderType[CommandBuilderType["SlashCommand"] = 1] = "SlashCommand";
|
|
11
|
+
})(CommandBuilderType = exports.CommandBuilderType || (exports.CommandBuilderType = {}));
|
|
@@ -2,39 +2,39 @@ import { MessageCommandExecuteData } from '../classes/builders/MessageCommandBui
|
|
|
2
2
|
import { SlashCommandBuilder, SlashCommandExecuteData } from '../classes/builders/SlashCommandBuilder';
|
|
3
3
|
import { CooledDownUser } from '../classes/CommandCooldownManager';
|
|
4
4
|
import { MessageCommandOptionManager } from '../classes/MessageCommandOptionManager';
|
|
5
|
-
import {
|
|
5
|
+
import { CommandBuilder } from '../types/builders';
|
|
6
6
|
/**
|
|
7
7
|
* Halted command's data
|
|
8
8
|
*/
|
|
9
|
-
export declare type
|
|
10
|
-
export interface
|
|
9
|
+
export declare type HaltedCommandData<Builder extends CommandBuilder = CommandBuilder> = CommandErrorData<Builder> | CommandCooldownData<Builder> | (Builder extends SlashCommandBuilder ? never : CommandInvalidArguments<Builder> | CommandMissingArguments<Builder>) | CommandMissingMemberPermissions<Builder> | CommandMissingBotPermissions<Builder>;
|
|
10
|
+
export interface CommandHaltBaseData<Builder extends CommandBuilder> {
|
|
11
11
|
executeData: Builder extends SlashCommandBuilder ? SlashCommandExecuteData : MessageCommandExecuteData;
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
14
|
-
reason:
|
|
13
|
+
export interface CommandErrorData<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
|
|
14
|
+
reason: HaltedCommandReason.Error;
|
|
15
15
|
error: any;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
18
|
-
reason:
|
|
17
|
+
export interface CommandCooldownData<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder>, CooledDownUser {
|
|
18
|
+
reason: HaltedCommandReason.Cooldown;
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
21
|
-
reason:
|
|
20
|
+
export interface CommandInvalidArguments<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
|
|
21
|
+
reason: HaltedCommandReason.InvalidArguments;
|
|
22
22
|
invalidArguments: MessageCommandOptionManager;
|
|
23
23
|
}
|
|
24
|
-
export interface
|
|
25
|
-
reason:
|
|
24
|
+
export interface CommandMissingArguments<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
|
|
25
|
+
reason: HaltedCommandReason.MissingArguments;
|
|
26
26
|
missingArguments: MessageCommandOptionManager;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
29
|
-
reason:
|
|
28
|
+
export interface CommandMissingMemberPermissions<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
|
|
29
|
+
reason: HaltedCommandReason.MissingMemberPermissions;
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
32
|
-
reason:
|
|
31
|
+
export interface CommandMissingBotPermissions<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
|
|
32
|
+
reason: HaltedCommandReason.MissingBotPermissions;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Command halt reasons
|
|
36
36
|
*/
|
|
37
|
-
export declare enum
|
|
37
|
+
export declare enum HaltedCommandReason {
|
|
38
38
|
Error = 0,
|
|
39
39
|
Cooldown = 1,
|
|
40
40
|
InvalidArguments = 2,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.HaltedCommandReason = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Command halt reasons
|
|
6
6
|
*/
|
|
7
|
-
var
|
|
8
|
-
(function (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})(
|
|
7
|
+
var HaltedCommandReason;
|
|
8
|
+
(function (HaltedCommandReason) {
|
|
9
|
+
HaltedCommandReason[HaltedCommandReason["Error"] = 0] = "Error";
|
|
10
|
+
HaltedCommandReason[HaltedCommandReason["Cooldown"] = 1] = "Cooldown";
|
|
11
|
+
HaltedCommandReason[HaltedCommandReason["InvalidArguments"] = 2] = "InvalidArguments";
|
|
12
|
+
HaltedCommandReason[HaltedCommandReason["MissingArguments"] = 3] = "MissingArguments";
|
|
13
|
+
HaltedCommandReason[HaltedCommandReason["MissingMemberPermissions"] = 4] = "MissingMemberPermissions";
|
|
14
|
+
HaltedCommandReason[HaltedCommandReason["MissingBotPermissions"] = 5] = "MissingBotPermissions";
|
|
15
|
+
})(HaltedCommandReason = exports.HaltedCommandReason || (exports.HaltedCommandReason = {}));
|
|
@@ -2,9 +2,9 @@ import { RecipleClient } from '../classes/RecipleClient';
|
|
|
2
2
|
import { Config } from '../classes/RecipleConfig';
|
|
3
3
|
import { RecipleModule, RecipleScript } from '../modules';
|
|
4
4
|
import { ApplicationCommandBuilder } from '../registerInteractionCommands';
|
|
5
|
-
import {
|
|
5
|
+
import { CommandBuilder } from './builders';
|
|
6
6
|
import { ApplicationCommandData, PermissionsBitField } from 'discord.js';
|
|
7
|
-
export interface
|
|
7
|
+
export interface RecipleClientAddModuleOptions {
|
|
8
8
|
/**
|
|
9
9
|
* The Module script
|
|
10
10
|
*/
|
|
@@ -18,7 +18,7 @@ export interface RecipleAddModuleOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
moduleInfo?: RecipleModule["info"];
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
21
|
+
export interface RegisterApplicationCommandsOptions {
|
|
22
22
|
/**
|
|
23
23
|
* Bot client
|
|
24
24
|
*/
|
|
@@ -32,8 +32,8 @@ export interface RecipleRegisterApplicationCommandsOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
guilds?: string | string[];
|
|
34
34
|
}
|
|
35
|
-
export interface
|
|
36
|
-
builder:
|
|
35
|
+
export interface UserHasCommandPermissionsOptions {
|
|
36
|
+
builder: CommandBuilder;
|
|
37
37
|
memberPermissions?: PermissionsBitField;
|
|
38
38
|
commandPermissions?: Config["commands"]["slashCommand"]["permissions"] | Config["commands"]["messageCommand"]["permissions"];
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "4.0.0-pre.
|
|
3
|
+
"version": "4.0.0-pre.2",
|
|
4
4
|
"bin": "bin/bin.js",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"url": "https://github.com/FalloutStudios/reciple/issues"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"clean": "
|
|
22
|
+
"clean": "yarn exec rimraf bin",
|
|
23
23
|
"build": "yarn clean && yarn exec tsc",
|
|
24
24
|
"build:publish": "yarn build && yarn npm publish && yarn build:docs && yarn publish:docs",
|
|
25
25
|
"build:pub-prerelease": "yarn build && yarn npm publish --tag pre",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/node": "^18.6.1",
|
|
60
60
|
"@types/semver": "^7.3.10",
|
|
61
61
|
"discord.js": "^14.0.3",
|
|
62
|
+
"rimraf": "^3.0.2",
|
|
62
63
|
"typedoc": "^0.23.9",
|
|
63
64
|
"typedoc-plugin-discord-types": "^1.0.2",
|
|
64
65
|
"typedoc-plugin-djs-links": "^1.2.0",
|