reciple 5.5.5 → 5.6.0
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/reciple/classes/RecipleClient.js +35 -23
- package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +12 -1
- package/dist/cjs/reciple/classes/builders/MessageCommandOptionBuilder.js +14 -0
- package/dist/cjs/reciple/classes/builders/SlashCommandBuilder.js +12 -1
- package/dist/cjs/reciple/permissions.js +0 -3
- package/dist/cjs/reciple/registerApplicationCommands.js +0 -1
- package/dist/cjs/reciple/util.js +13 -1
- package/dist/cjs/reciple/version.js +1 -0
- package/dist/types/reciple/classes/CommandCooldownManager.d.ts +18 -0
- package/dist/types/reciple/classes/RecipleClient.d.ts +22 -10
- package/dist/types/reciple/classes/RecipleConfig.d.ts +6 -0
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +52 -14
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +10 -0
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +29 -14
- package/dist/types/reciple/modules.d.ts +36 -4
- package/dist/types/reciple/permissions.d.ts +4 -2
- package/dist/types/reciple/types/builders.d.ts +16 -16
- package/dist/types/reciple/types/commands.d.ts +30 -11
- package/dist/types/reciple/types/paramOptions.d.ts +14 -2
- package/dist/types/reciple/util.d.ts +10 -1
- package/package.json +8 -6
|
@@ -12,14 +12,15 @@ const commands_1 = require("../types/commands");
|
|
|
12
12
|
const permissions_1 = require("../permissions");
|
|
13
13
|
const CommandCooldownManager_1 = require("./CommandCooldownManager");
|
|
14
14
|
const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
|
|
15
|
-
const fallout_utility_1 = require("fallout-utility");
|
|
16
15
|
const RecipleConfig_1 = require("./RecipleConfig");
|
|
17
16
|
const modules_1 = require("../modules");
|
|
17
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
18
18
|
const logger_1 = require("../logger");
|
|
19
19
|
const version_1 = require("../version");
|
|
20
20
|
const flags_1 = require("../flags");
|
|
21
21
|
const path_1 = __importDefault(require("path"));
|
|
22
22
|
const discord_js_1 = require("discord.js");
|
|
23
|
+
const util_1 = require("../util");
|
|
23
24
|
class RecipleClient extends discord_js_1.Client {
|
|
24
25
|
/**
|
|
25
26
|
* @param options Client options
|
|
@@ -33,15 +34,13 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
33
34
|
this.modules = [];
|
|
34
35
|
this.version = version_1.version;
|
|
35
36
|
this.logger = (0, logger_1.createLogger)(!!options.config?.fileLogging.stringifyLoggedJSON, options.config?.fileLogging.debugmode);
|
|
36
|
-
if (!options.config)
|
|
37
|
-
throw new Error('Config is not defined.');
|
|
38
37
|
this.config = { ...this.config, ...(options.config ?? {}) };
|
|
39
38
|
if (this.config.fileLogging.enabled)
|
|
40
39
|
this.logger.logFile(path_1.default.join(flags_1.cwd, this.config.fileLogging.logFilePath ?? 'logs/latest.log'), false);
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
|
-
* Load modules from
|
|
44
|
-
* @param folders
|
|
42
|
+
* Load and start modules from given folders
|
|
43
|
+
* @param folders folders that contains the modules you want to load
|
|
45
44
|
*/
|
|
46
45
|
async startModules(...folders) {
|
|
47
46
|
folders = (0, discord_js_1.normalizeArray)(folders).map(f => path_1.default.join(flags_1.cwd, f));
|
|
@@ -59,9 +58,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
59
58
|
return this;
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
62
|
-
* Execute
|
|
61
|
+
* Execute {@link RecipleModule['onLoad']} from client modules and register application commands if enabled
|
|
63
62
|
*/
|
|
64
63
|
async loadModules() {
|
|
64
|
+
if (!this.isReady())
|
|
65
|
+
throw new Error('Client is not ready');
|
|
65
66
|
for (const m in this.modules) {
|
|
66
67
|
const index = (m);
|
|
67
68
|
const module_ = this.modules[index];
|
|
@@ -94,23 +95,23 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
94
95
|
this.logger.info(`${this.commands.messageCommands.size} message commands loaded.`);
|
|
95
96
|
this.logger.info(`${this.commands.slashCommands.size} slash commands loaded.`);
|
|
96
97
|
}
|
|
97
|
-
if (this.config.commands.slashCommand.registerCommands)
|
|
98
|
-
await (
|
|
99
|
-
client: this,
|
|
100
|
-
commands: [...this.commands.slashCommands.toJSON(), ...this.additionalApplicationCommands],
|
|
101
|
-
guilds: this.config.commands.slashCommand.guilds
|
|
102
|
-
});
|
|
103
|
-
}
|
|
98
|
+
if (this.config.commands.slashCommand.registerCommands)
|
|
99
|
+
await this.registerClientApplicationCommands();
|
|
104
100
|
return this;
|
|
105
101
|
}
|
|
106
102
|
/**
|
|
107
103
|
* Add module
|
|
108
104
|
* @param options Module options
|
|
105
|
+
* @deprecated This is very stupid, Just add it manually
|
|
109
106
|
*/
|
|
110
107
|
async addModule(options) {
|
|
108
|
+
(0, util_1.deprecationWarning)('Add modules manually It\'s not that hard');
|
|
109
|
+
// TODO: DEPRECATED!
|
|
111
110
|
const { script } = options;
|
|
112
111
|
const registerCommands = options.registerApplicationCommands;
|
|
113
112
|
const info = options.moduleInfo;
|
|
113
|
+
if (!this.isReady())
|
|
114
|
+
throw new Error('Client is not ready');
|
|
114
115
|
this.modules.push({
|
|
115
116
|
script,
|
|
116
117
|
info: {
|
|
@@ -130,11 +131,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
130
131
|
this.addCommand(command);
|
|
131
132
|
}
|
|
132
133
|
if (registerCommands)
|
|
133
|
-
await (
|
|
134
|
-
client: this,
|
|
135
|
-
commands: [...this.commands.slashCommands.toJSON(), ...this.additionalApplicationCommands],
|
|
136
|
-
guilds: this.config.commands.slashCommand.guilds
|
|
137
|
-
});
|
|
134
|
+
await this.registerClientApplicationCommands();
|
|
138
135
|
}
|
|
139
136
|
/**
|
|
140
137
|
* Add slash or message command to client
|
|
@@ -156,10 +153,14 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
156
153
|
* Listed to command executions
|
|
157
154
|
*/
|
|
158
155
|
addCommandListeners() {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
this.on('messageCreate', (message) => {
|
|
157
|
+
if (this.config.commands.messageCommand.enabled)
|
|
158
|
+
this.messageCommandExecute(message);
|
|
159
|
+
});
|
|
160
|
+
this.on('interactionCreate', (interaction) => {
|
|
161
|
+
if (this.config.commands.slashCommand.enabled)
|
|
162
|
+
this.slashCommandExecute(interaction);
|
|
163
|
+
});
|
|
163
164
|
return this;
|
|
164
165
|
}
|
|
165
166
|
/**
|
|
@@ -285,6 +286,17 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
285
286
|
message.reply(this.getConfigMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
|
|
286
287
|
}
|
|
287
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Registers client slash commands and other application commands
|
|
291
|
+
*/
|
|
292
|
+
async registerClientApplicationCommands() {
|
|
293
|
+
await (0, registerApplicationCommands_1.registerApplicationCommands)({
|
|
294
|
+
client: this,
|
|
295
|
+
commands: [...this.commands.slashCommands.toJSON(), ...this.additionalApplicationCommands],
|
|
296
|
+
guilds: this.config.commands.slashCommand.guilds
|
|
297
|
+
});
|
|
298
|
+
this.emit('recipleRegisterApplicationCommands');
|
|
299
|
+
}
|
|
288
300
|
/**
|
|
289
301
|
* Get a message from config
|
|
290
302
|
* @param messageKey Config messages key
|
|
@@ -313,7 +325,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
313
325
|
return !!this.config.fileLogging.clientLogs;
|
|
314
326
|
}
|
|
315
327
|
/**
|
|
316
|
-
* Emits the "recipleReplyError" event
|
|
328
|
+
* Emits the {@link RecipleClientEvents["recipleReplyError"]} event
|
|
317
329
|
* @param error Received Error
|
|
318
330
|
*/
|
|
319
331
|
_replyError(error) {
|
|
@@ -116,7 +116,7 @@ class MessageCommandBuilder {
|
|
|
116
116
|
throw new TypeError('option with name "' + option.name + '" already exists.');
|
|
117
117
|
if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
|
|
118
118
|
throw new TypeError('All required options must be before optional options.');
|
|
119
|
-
this.options
|
|
119
|
+
this.options.push(option);
|
|
120
120
|
return this;
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
@@ -176,23 +176,34 @@ class MessageCommandBuilder {
|
|
|
176
176
|
options: this.options.map(o => o.toJSON()),
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Resolve message command data/builder
|
|
181
|
+
* @param commandData Command data to resolve
|
|
182
|
+
*/
|
|
179
183
|
static resolveMessageCommand(commandData) {
|
|
180
184
|
return this.isMessageCommandBuilder(commandData) ? commandData : new MessageCommandBuilder(commandData);
|
|
181
185
|
}
|
|
182
186
|
/**
|
|
183
187
|
* Is a message command builder
|
|
188
|
+
* @param builder data to check
|
|
184
189
|
*/
|
|
185
190
|
static isMessageCommandBuilder(builder) {
|
|
186
191
|
return builder instanceof MessageCommandBuilder;
|
|
187
192
|
}
|
|
188
193
|
/**
|
|
189
194
|
* Is a message command execute data
|
|
195
|
+
* @param executeData data to check
|
|
190
196
|
*/
|
|
191
197
|
static isMessageCommandExecuteData(executeData) {
|
|
192
198
|
return executeData.builder !== undefined && this.isMessageCommandBuilder(executeData.builder);
|
|
193
199
|
}
|
|
194
200
|
}
|
|
195
201
|
exports.MessageCommandBuilder = MessageCommandBuilder;
|
|
202
|
+
/**
|
|
203
|
+
* Validate message command options
|
|
204
|
+
* @param builder Command builder
|
|
205
|
+
* @param options Parsed command args
|
|
206
|
+
*/
|
|
196
207
|
async function validateMessageCommandOptions(builder, options) {
|
|
197
208
|
const args = options.args || [];
|
|
198
209
|
const required = builder.options.filter(o => o.required);
|
|
@@ -67,5 +67,19 @@ class MessageCommandOptionBuilder {
|
|
|
67
67
|
validator: this.validator,
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolves message command option data/builder
|
|
72
|
+
* @param option Option data to resolve
|
|
73
|
+
*/
|
|
74
|
+
static resolveMessageCommandOption(option) {
|
|
75
|
+
return this.isMessageCommandOption(option) ? option : new MessageCommandOptionBuilder(option);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Is a Message command option builder
|
|
79
|
+
* @param builder data to check
|
|
80
|
+
*/
|
|
81
|
+
static isMessageCommandOption(builder) {
|
|
82
|
+
return builder instanceof MessageCommandOptionBuilder;
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
85
|
exports.MessageCommandOptionBuilder = MessageCommandOptionBuilder;
|
|
@@ -58,7 +58,9 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
58
58
|
}
|
|
59
59
|
setRequiredMemberPermissions(...permissions) {
|
|
60
60
|
this.requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
|
|
61
|
-
this.setDefaultMemberPermissions(
|
|
61
|
+
this.setDefaultMemberPermissions(this.requiredMemberPermissions.length
|
|
62
|
+
? new discord_js_1.PermissionsBitField(this.requiredMemberPermissions).bitfield
|
|
63
|
+
: undefined);
|
|
62
64
|
return this;
|
|
63
65
|
}
|
|
64
66
|
setHalt(halt) {
|
|
@@ -77,6 +79,8 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
77
79
|
}
|
|
78
80
|
/**
|
|
79
81
|
* Add option builder to command builder
|
|
82
|
+
* @param builder Command/Subcommand builder
|
|
83
|
+
* @param option Option builder
|
|
80
84
|
*/
|
|
81
85
|
static addOption(builder, option) {
|
|
82
86
|
if (option instanceof discord_js_1.SlashCommandAttachmentOption) {
|
|
@@ -118,6 +122,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
120
124
|
* Resolve option data
|
|
125
|
+
* @param option Option dara to resolve
|
|
121
126
|
*/
|
|
122
127
|
static resolveOption(option) {
|
|
123
128
|
let builder;
|
|
@@ -197,17 +202,23 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
197
202
|
.setNameLocalizations(option.nameLocalizations ?? null)
|
|
198
203
|
.setDescriptionLocalizations(option.descriptionLocalizations ?? null);
|
|
199
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Resolve slash command data/builder
|
|
207
|
+
* @param commandData Command data to resolve
|
|
208
|
+
*/
|
|
200
209
|
static resolveSlashCommand(commandData) {
|
|
201
210
|
return this.isSlashCommandBuilder(commandData) ? commandData : new SlashCommandBuilder(commandData);
|
|
202
211
|
}
|
|
203
212
|
/**
|
|
204
213
|
* Is a slash command builder
|
|
214
|
+
* @param builder data to check
|
|
205
215
|
*/
|
|
206
216
|
static isSlashCommandBuilder(builder) {
|
|
207
217
|
return builder instanceof SlashCommandBuilder;
|
|
208
218
|
}
|
|
209
219
|
/**
|
|
210
220
|
* Is a slash command execute data
|
|
221
|
+
* @param executeData data to check
|
|
211
222
|
*/
|
|
212
223
|
static isSlashCommandExecuteData(executeData) {
|
|
213
224
|
return executeData.builder !== undefined && this.isSlashCommandBuilder(executeData.builder);
|
|
@@ -16,9 +16,6 @@ function userHasCommandPermissions(options) {
|
|
|
16
16
|
return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
|
|
17
17
|
}
|
|
18
18
|
exports.userHasCommandPermissions = userHasCommandPermissions;
|
|
19
|
-
/**
|
|
20
|
-
* @param guildOrChannel Check permission in a guild or channel
|
|
21
|
-
*/
|
|
22
19
|
function botHasExecutePermissions(guildOrChannel, requiredPermissions) {
|
|
23
20
|
if (!requiredPermissions?.length)
|
|
24
21
|
return true;
|
package/dist/cjs/reciple/util.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isClass = void 0;
|
|
3
|
+
exports.deprecationWarning = exports.isClass = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Check if an object is a class
|
|
6
|
+
* @param object Object to identify
|
|
7
|
+
*/
|
|
4
8
|
function isClass(object) {
|
|
5
9
|
const isClassConstructor = object.constructor && object.constructor.toString().substring(0, 5) === 'class';
|
|
6
10
|
if (object.prototype === undefined)
|
|
@@ -9,3 +13,11 @@ function isClass(object) {
|
|
|
9
13
|
return isClassConstructor || isPrototypeClassConstructor;
|
|
10
14
|
}
|
|
11
15
|
exports.isClass = isClass;
|
|
16
|
+
/**
|
|
17
|
+
* Emit process warning about deprecated method/function
|
|
18
|
+
* @param content Warning content
|
|
19
|
+
*/
|
|
20
|
+
function deprecationWarning(content) {
|
|
21
|
+
process.emitWarning(content, 'DeprecationWarning');
|
|
22
|
+
}
|
|
23
|
+
exports.deprecationWarning = deprecationWarning;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isSupportedVersion = exports.parseVersion = exports.isValidVersion = exports.rawVersion = exports.version = void 0;
|
|
7
7
|
const semver_1 = __importDefault(require("semver"));
|
|
8
|
+
// TODO: ESM support
|
|
8
9
|
/**
|
|
9
10
|
* Current reciple version
|
|
10
11
|
*/
|
|
@@ -4,11 +4,29 @@ import { CommandBuilderType } from '../types/builders';
|
|
|
4
4
|
* cooled-down user object interface
|
|
5
5
|
*/
|
|
6
6
|
export interface CooledDownUser {
|
|
7
|
+
/**
|
|
8
|
+
* Cooled-down user
|
|
9
|
+
*/
|
|
7
10
|
user: User;
|
|
11
|
+
/**
|
|
12
|
+
* Cooled-down command name
|
|
13
|
+
*/
|
|
8
14
|
command: string;
|
|
15
|
+
/**
|
|
16
|
+
* Command type
|
|
17
|
+
*/
|
|
9
18
|
type: CommandBuilderType;
|
|
19
|
+
/**
|
|
20
|
+
* In guild
|
|
21
|
+
*/
|
|
10
22
|
guild?: Guild | null;
|
|
23
|
+
/**
|
|
24
|
+
* Cooled-down channel
|
|
25
|
+
*/
|
|
11
26
|
channel?: TextBasedChannel;
|
|
27
|
+
/**
|
|
28
|
+
* Cooldown expiration
|
|
29
|
+
*/
|
|
12
30
|
expireTime: number;
|
|
13
31
|
}
|
|
14
32
|
/**
|
|
@@ -5,12 +5,12 @@ import { ApplicationCommandBuilder } from '../registerApplicationCommands';
|
|
|
5
5
|
import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
|
|
6
6
|
import { CommandCooldownManager } from './CommandCooldownManager';
|
|
7
7
|
import { RecipleClientAddModuleOptions } from '../types/paramOptions';
|
|
8
|
-
import { Logger as ILogger } from 'fallout-utility';
|
|
9
8
|
import { Config } from './RecipleConfig';
|
|
10
9
|
import { RecipleModule } from '../modules';
|
|
10
|
+
import { Logger } from 'fallout-utility';
|
|
11
11
|
import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Collection, Interaction, Message, RestOrArray } from 'discord.js';
|
|
12
12
|
/**
|
|
13
|
-
* Options for
|
|
13
|
+
* Options for {@link RecipleClient}
|
|
14
14
|
*/
|
|
15
15
|
export interface RecipleClientOptions extends ClientOptions {
|
|
16
16
|
config?: Config;
|
|
@@ -19,7 +19,13 @@ export interface RecipleClientOptions extends ClientOptions {
|
|
|
19
19
|
* Reciple client commands
|
|
20
20
|
*/
|
|
21
21
|
export interface RecipleClientCommands {
|
|
22
|
+
/**
|
|
23
|
+
* Collection of loaded slash commands
|
|
24
|
+
*/
|
|
22
25
|
slashCommands: Collection<string, AnySlashCommandBuilder>;
|
|
26
|
+
/**
|
|
27
|
+
* Collection of loaded message commands
|
|
28
|
+
*/
|
|
23
29
|
messageCommands: Collection<string, MessageCommandBuilder>;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
@@ -28,6 +34,7 @@ export interface RecipleClientCommands {
|
|
|
28
34
|
export interface RecipleClientEvents extends ClientEvents {
|
|
29
35
|
recipleCommandExecute: [executeData: AnyCommandExecuteData];
|
|
30
36
|
recipleCommandHalt: [haltData: AnyCommandHaltData];
|
|
37
|
+
recipleRegisterApplicationCommands: [];
|
|
31
38
|
recipleReplyError: [error: unknown];
|
|
32
39
|
}
|
|
33
40
|
/**
|
|
@@ -52,24 +59,25 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
52
59
|
additionalApplicationCommands: (ApplicationCommandBuilder | ApplicationCommandData)[];
|
|
53
60
|
cooldowns: CommandCooldownManager;
|
|
54
61
|
modules: RecipleModule[];
|
|
55
|
-
logger:
|
|
62
|
+
logger: Logger;
|
|
56
63
|
version: string;
|
|
57
64
|
/**
|
|
58
65
|
* @param options Client options
|
|
59
66
|
*/
|
|
60
67
|
constructor(options: RecipleClientOptions);
|
|
61
68
|
/**
|
|
62
|
-
* Load modules from
|
|
63
|
-
* @param folders
|
|
69
|
+
* Load and start modules from given folders
|
|
70
|
+
* @param folders folders that contains the modules you want to load
|
|
64
71
|
*/
|
|
65
|
-
startModules(...folders: RestOrArray<string>): Promise<
|
|
72
|
+
startModules(...folders: RestOrArray<string>): Promise<this>;
|
|
66
73
|
/**
|
|
67
|
-
* Execute
|
|
74
|
+
* Execute {@link RecipleModule['onLoad']} from client modules and register application commands if enabled
|
|
68
75
|
*/
|
|
69
|
-
loadModules(): Promise<
|
|
76
|
+
loadModules(): Promise<this>;
|
|
70
77
|
/**
|
|
71
78
|
* Add module
|
|
72
79
|
* @param options Module options
|
|
80
|
+
* @deprecated This is very stupid, Just add it manually
|
|
73
81
|
*/
|
|
74
82
|
addModule(options: RecipleClientAddModuleOptions): Promise<void>;
|
|
75
83
|
/**
|
|
@@ -92,6 +100,10 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
92
100
|
* @param prefix Message command prefix
|
|
93
101
|
*/
|
|
94
102
|
messageCommandExecute(message: Message, prefix?: string): Promise<void | MessageCommandExecuteData>;
|
|
103
|
+
/**
|
|
104
|
+
* Registers client slash commands and other application commands
|
|
105
|
+
*/
|
|
106
|
+
registerClientApplicationCommands(): Promise<void>;
|
|
95
107
|
/**
|
|
96
108
|
* Get a message from config
|
|
97
109
|
* @param messageKey Config messages key
|
|
@@ -110,7 +122,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
110
122
|
*/
|
|
111
123
|
isClientLogsEnabled(): boolean;
|
|
112
124
|
/**
|
|
113
|
-
* Emits the "recipleReplyError" event
|
|
125
|
+
* Emits the {@link RecipleClientEvents["recipleReplyError"]} event
|
|
114
126
|
* @param error Received Error
|
|
115
127
|
*/
|
|
116
128
|
protected _replyError(error: unknown): void;
|
|
@@ -122,7 +134,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
122
134
|
protected _haltCommand(command: SlashCommandBuilder, haltData: SlashCommandHaltData): Promise<boolean>;
|
|
123
135
|
protected _haltCommand(command: MessageCommandBuilder, haltData: MessageCommandHaltData): Promise<boolean>;
|
|
124
136
|
/**
|
|
125
|
-
* Executes a command
|
|
137
|
+
* Executes a command's {@link SharedCommandBuilderProperties["execute"]} method
|
|
126
138
|
* @param command Command builder
|
|
127
139
|
* @param executeData Command execute data
|
|
128
140
|
*/
|
|
@@ -3,7 +3,13 @@ import { ClientOptions, PermissionResolvable } from 'discord.js';
|
|
|
3
3
|
* Command permissions config object interface
|
|
4
4
|
*/
|
|
5
5
|
export interface ConfigCommandPermissions {
|
|
6
|
+
/**
|
|
7
|
+
* Command name
|
|
8
|
+
*/
|
|
6
9
|
command: string;
|
|
10
|
+
/**
|
|
11
|
+
* Override command builder permissions
|
|
12
|
+
*/
|
|
7
13
|
permissions: PermissionResolvable[];
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
@@ -3,42 +3,69 @@ import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
|
|
|
3
3
|
import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
|
|
4
4
|
import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
|
|
5
5
|
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
6
|
-
import { Command
|
|
6
|
+
import { Command } from 'fallout-utility';
|
|
7
7
|
/**
|
|
8
8
|
* Execute data for message command
|
|
9
9
|
*/
|
|
10
|
-
export interface MessageCommandExecuteData<T
|
|
10
|
+
export interface MessageCommandExecuteData<T = unknown> extends BaseCommandExecuteData {
|
|
11
|
+
/**
|
|
12
|
+
* Command message
|
|
13
|
+
*/
|
|
11
14
|
message: Message;
|
|
15
|
+
/**
|
|
16
|
+
* Command option args
|
|
17
|
+
*/
|
|
12
18
|
options: MessageCommandOptionManager;
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Command parsed args
|
|
21
|
+
*/
|
|
22
|
+
command: Command;
|
|
23
|
+
/**
|
|
24
|
+
* Command builder
|
|
25
|
+
*/
|
|
14
26
|
builder: MessageCommandBuilder<T>;
|
|
15
27
|
}
|
|
16
28
|
/**
|
|
17
29
|
* Validated message command option
|
|
18
30
|
*/
|
|
19
31
|
export interface MessageCommandValidatedOption {
|
|
32
|
+
/**
|
|
33
|
+
* Option name
|
|
34
|
+
*/
|
|
20
35
|
name: string;
|
|
21
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Option value
|
|
38
|
+
*/
|
|
39
|
+
value?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Is the option required
|
|
42
|
+
*/
|
|
22
43
|
required: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Is the option invalid
|
|
46
|
+
*/
|
|
23
47
|
invalid: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Is the option missing
|
|
50
|
+
*/
|
|
24
51
|
missing: boolean;
|
|
25
52
|
}
|
|
26
53
|
/**
|
|
27
54
|
* Halt data for message command
|
|
28
55
|
*/
|
|
29
|
-
export declare type MessageCommandHaltData = CommandHaltData<CommandBuilderType.MessageCommand>;
|
|
56
|
+
export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.MessageCommand, T>;
|
|
30
57
|
/**
|
|
31
58
|
* Message command halt function
|
|
32
59
|
*/
|
|
33
|
-
export declare type MessageCommandHaltFunction = CommandHaltFunction<CommandBuilderType.MessageCommand>;
|
|
60
|
+
export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.MessageCommand, T>;
|
|
34
61
|
/**
|
|
35
62
|
* Message command execute function
|
|
36
63
|
*/
|
|
37
|
-
export declare type MessageCommandExecuteFunction = CommandExecuteFunction<CommandBuilderType.MessageCommand>;
|
|
64
|
+
export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.MessageCommand, T>;
|
|
38
65
|
/**
|
|
39
66
|
* Reciple builder for message command
|
|
40
67
|
*/
|
|
41
|
-
export declare class MessageCommandBuilder<T
|
|
68
|
+
export declare class MessageCommandBuilder<T = unknown> implements SharedCommandBuilderProperties<T> {
|
|
42
69
|
readonly type = CommandBuilderType.MessageCommand;
|
|
43
70
|
name: string;
|
|
44
71
|
description: string;
|
|
@@ -50,8 +77,8 @@ export declare class MessageCommandBuilder<T extends unknown = any> implements S
|
|
|
50
77
|
requiredMemberPermissions: PermissionResolvable[];
|
|
51
78
|
allowExecuteInDM: boolean;
|
|
52
79
|
allowExecuteByBots: boolean;
|
|
53
|
-
halt?: MessageCommandHaltFunction
|
|
54
|
-
execute: MessageCommandExecuteFunction
|
|
80
|
+
halt?: MessageCommandHaltFunction<T>;
|
|
81
|
+
execute: MessageCommandExecuteFunction<T>;
|
|
55
82
|
metadata?: T;
|
|
56
83
|
constructor(data?: Partial<Omit<MessageCommandData<T>, "type">>);
|
|
57
84
|
/**
|
|
@@ -92,21 +119,32 @@ export declare class MessageCommandBuilder<T extends unknown = any> implements S
|
|
|
92
119
|
setCooldown(cooldown: number): this;
|
|
93
120
|
setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
94
121
|
setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
95
|
-
setHalt(halt?: MessageCommandHaltFunction | null): this;
|
|
96
|
-
setExecute(execute: MessageCommandExecuteFunction): this;
|
|
122
|
+
setHalt(halt?: MessageCommandHaltFunction<T> | null): this;
|
|
123
|
+
setExecute(execute: MessageCommandExecuteFunction<T>): this;
|
|
97
124
|
setMetadata(metadata?: T): this;
|
|
98
125
|
/**
|
|
99
126
|
* Returns JSON object of this builder
|
|
100
127
|
*/
|
|
101
128
|
toJSON(): MessageCommandData<T>;
|
|
102
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Resolve message command data/builder
|
|
131
|
+
* @param commandData Command data to resolve
|
|
132
|
+
*/
|
|
133
|
+
static resolveMessageCommand<T = unknown>(commandData: MessageCommandData<T> | MessageCommandBuilder<T>): MessageCommandBuilder<T>;
|
|
103
134
|
/**
|
|
104
135
|
* Is a message command builder
|
|
136
|
+
* @param builder data to check
|
|
105
137
|
*/
|
|
106
138
|
static isMessageCommandBuilder<T>(builder: unknown): builder is MessageCommandBuilder<T>;
|
|
107
139
|
/**
|
|
108
140
|
* Is a message command execute data
|
|
141
|
+
* @param executeData data to check
|
|
109
142
|
*/
|
|
110
143
|
static isMessageCommandExecuteData(executeData: unknown): executeData is MessageCommandExecuteData;
|
|
111
144
|
}
|
|
112
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Validate message command options
|
|
147
|
+
* @param builder Command builder
|
|
148
|
+
* @param options Parsed command args
|
|
149
|
+
*/
|
|
150
|
+
export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: Command): Promise<MessageCommandOptionManager>;
|
|
@@ -30,4 +30,14 @@ export declare class MessageCommandOptionBuilder {
|
|
|
30
30
|
*/
|
|
31
31
|
setValidator(validator: (value: string) => Awaitable<boolean>): this;
|
|
32
32
|
toJSON(): MessageCommandOptionData;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves message command option data/builder
|
|
35
|
+
* @param option Option data to resolve
|
|
36
|
+
*/
|
|
37
|
+
static resolveMessageCommandOption(option: MessageCommandOptionBuilder | MessageCommandOptionBuilder): MessageCommandOptionBuilder;
|
|
38
|
+
/**
|
|
39
|
+
* Is a Message command option builder
|
|
40
|
+
* @param builder data to check
|
|
41
|
+
*/
|
|
42
|
+
static isMessageCommandOption(builder: unknown): builder is MessageCommandOptionBuilder;
|
|
33
43
|
}
|
|
@@ -4,25 +4,31 @@ import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCo
|
|
|
4
4
|
/**
|
|
5
5
|
* Execute data for slash command
|
|
6
6
|
*/
|
|
7
|
-
export interface SlashCommandExecuteData<T
|
|
7
|
+
export interface SlashCommandExecuteData<T = unknown> extends BaseCommandExecuteData {
|
|
8
|
+
/**
|
|
9
|
+
* Command interaction
|
|
10
|
+
*/
|
|
8
11
|
interaction: ChatInputCommandInteraction;
|
|
12
|
+
/**
|
|
13
|
+
* Command Builder
|
|
14
|
+
*/
|
|
9
15
|
builder: AnySlashCommandBuilder<T>;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* Slash command halt data
|
|
13
19
|
*/
|
|
14
|
-
export declare type SlashCommandHaltData = CommandHaltData<CommandBuilderType.SlashCommand>;
|
|
20
|
+
export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.SlashCommand, T>;
|
|
15
21
|
/**
|
|
16
22
|
* Slash command halt function
|
|
17
23
|
*/
|
|
18
|
-
export declare type SlashCommandHaltFunction = CommandHaltFunction<CommandBuilderType.SlashCommand>;
|
|
24
|
+
export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.SlashCommand, T>;
|
|
19
25
|
/**
|
|
20
26
|
* Slash command execute function
|
|
21
27
|
*/
|
|
22
|
-
export declare type SlashCommandExecuteFunction = CommandExecuteFunction<CommandBuilderType.SlashCommand>;
|
|
23
|
-
export declare type SlashCommandSubcommandsOnlyBuilder<T
|
|
24
|
-
export declare type SlashCommandOptionsOnlyBuilder<T
|
|
25
|
-
export interface SlashCommandBuilder<T
|
|
28
|
+
export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.SlashCommand, T>;
|
|
29
|
+
export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, "addBooleanOption" | "addUserOption" | "addChannelOption" | "addRoleOption" | "addAttachmentOption" | "addMentionableOption" | "addStringOption" | "addIntegerOption" | "addNumberOption">;
|
|
30
|
+
export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, "addSubcommand" | "addSubcommandGroup">;
|
|
31
|
+
export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
|
|
26
32
|
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
|
27
33
|
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
|
28
34
|
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
|
|
@@ -38,36 +44,45 @@ export interface SlashCommandBuilder<T extends unknown = any> extends DiscordJsS
|
|
|
38
44
|
/**
|
|
39
45
|
* Reciple builder for slash command
|
|
40
46
|
*/
|
|
41
|
-
export declare class SlashCommandBuilder<T
|
|
47
|
+
export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
|
|
42
48
|
readonly type = CommandBuilderType.SlashCommand;
|
|
43
49
|
cooldown: number;
|
|
44
50
|
requiredBotPermissions: PermissionResolvable[];
|
|
45
51
|
requiredMemberPermissions: PermissionResolvable[];
|
|
46
|
-
halt?: SlashCommandHaltFunction
|
|
47
|
-
execute: SlashCommandExecuteFunction
|
|
52
|
+
halt?: SlashCommandHaltFunction<T>;
|
|
53
|
+
execute: SlashCommandExecuteFunction<T>;
|
|
48
54
|
metadata?: T;
|
|
49
55
|
constructor(data?: Partial<Omit<SlashCommandData<T>, "type">>);
|
|
50
56
|
setCooldown(cooldown: number): this;
|
|
51
57
|
setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
52
58
|
setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
53
|
-
setHalt(halt?: SlashCommandHaltFunction | null): this;
|
|
54
|
-
setExecute(execute: SlashCommandExecuteFunction): this;
|
|
59
|
+
setHalt(halt?: SlashCommandHaltFunction<T> | null): this;
|
|
60
|
+
setExecute(execute: SlashCommandExecuteFunction<T>): this;
|
|
55
61
|
setMetadata(metadata?: T): this;
|
|
56
62
|
/**
|
|
57
63
|
* Add option builder to command builder
|
|
64
|
+
* @param builder Command/Subcommand builder
|
|
65
|
+
* @param option Option builder
|
|
58
66
|
*/
|
|
59
67
|
static addOption(builder: SharedSlashCommandOptions | SlashCommandBuilder, option: AnySlashCommandOptionBuilder): SharedSlashCommandOptions;
|
|
60
68
|
/**
|
|
61
69
|
* Resolve option data
|
|
70
|
+
* @param option Option dara to resolve
|
|
62
71
|
*/
|
|
63
72
|
static resolveOption<T extends AnySlashCommandOptionBuilder>(option: AnySlashCommandOptionData): T;
|
|
64
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Resolve slash command data/builder
|
|
75
|
+
* @param commandData Command data to resolve
|
|
76
|
+
*/
|
|
77
|
+
static resolveSlashCommand<T = unknown>(commandData: SlashCommandData<T> | AnySlashCommandBuilder<T>): AnySlashCommandBuilder<T>;
|
|
65
78
|
/**
|
|
66
79
|
* Is a slash command builder
|
|
80
|
+
* @param builder data to check
|
|
67
81
|
*/
|
|
68
|
-
static isSlashCommandBuilder<T
|
|
82
|
+
static isSlashCommandBuilder<T = unknown>(builder: unknown): builder is AnySlashCommandBuilder<T>;
|
|
69
83
|
/**
|
|
70
84
|
* Is a slash command execute data
|
|
85
|
+
* @param executeData data to check
|
|
71
86
|
*/
|
|
72
87
|
static isSlashCommandExecuteData(executeData: unknown): executeData is SlashCommandExecuteData;
|
|
73
88
|
}
|
|
@@ -1,26 +1,58 @@
|
|
|
1
1
|
import { AnyCommandBuilder, AnyCommandData } from './types/builders';
|
|
2
2
|
import { RecipleClient } from './classes/RecipleClient';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Loaded modules and commands
|
|
5
|
+
*/
|
|
6
|
+
export interface LoadedModules {
|
|
4
7
|
commands: AnyCommandBuilder[];
|
|
5
8
|
modules: RecipleModule[];
|
|
6
|
-
}
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* Reciple script object
|
|
9
12
|
*/
|
|
10
13
|
export interface RecipleScript {
|
|
14
|
+
/**
|
|
15
|
+
* Supported reciple versions
|
|
16
|
+
*/
|
|
11
17
|
versions: string | string[];
|
|
18
|
+
/**
|
|
19
|
+
* Module commands
|
|
20
|
+
*/
|
|
12
21
|
commands?: (AnyCommandBuilder | AnyCommandData)[];
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Action on bot ready
|
|
24
|
+
* @param client Bot client
|
|
25
|
+
*/
|
|
26
|
+
onLoad?(client: RecipleClient<true>): void | Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Action on module start
|
|
29
|
+
* @param client Bot client
|
|
30
|
+
*/
|
|
31
|
+
onStart(client: RecipleClient<false>): boolean | Promise<boolean>;
|
|
15
32
|
}
|
|
16
33
|
/**
|
|
17
34
|
* Reciple module object
|
|
18
35
|
*/
|
|
19
36
|
export interface RecipleModule {
|
|
37
|
+
/**
|
|
38
|
+
* Module script
|
|
39
|
+
*/
|
|
20
40
|
script: RecipleScript;
|
|
41
|
+
/**
|
|
42
|
+
* Module local information
|
|
43
|
+
*/
|
|
21
44
|
info: {
|
|
45
|
+
/**
|
|
46
|
+
* Module file name
|
|
47
|
+
*/
|
|
22
48
|
filename?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Supported reciple versions
|
|
51
|
+
*/
|
|
23
52
|
versions: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Module local file path
|
|
55
|
+
*/
|
|
24
56
|
path?: string;
|
|
25
57
|
};
|
|
26
58
|
}
|
|
@@ -7,11 +7,13 @@ import { UserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
|
7
7
|
export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Check if the bot has the required permissions in a guild
|
|
10
|
-
* @param guild Check if the bot has the required permissions in
|
|
10
|
+
* @param guild Check if the bot has the required permissions in this guild
|
|
11
11
|
* @param requiredPermissions Required guild bot permissions
|
|
12
12
|
*/
|
|
13
13
|
export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Check if the bot has the required permissions in a channel
|
|
16
|
+
* @param channel Check if the bot has the required permissions in this channel
|
|
17
|
+
* @param requiredPermissions Required guild bot permissions
|
|
16
18
|
*/
|
|
17
19
|
export declare function botHasExecutePermissions(channel?: GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
@@ -5,31 +5,31 @@ import { MessageCommandOptionBuilder } from '../classes/builders/MessageCommandO
|
|
|
5
5
|
/**
|
|
6
6
|
* Any command builders
|
|
7
7
|
*/
|
|
8
|
-
export declare type AnyCommandBuilder<T
|
|
8
|
+
export declare type AnyCommandBuilder<T = unknown> = AnySlashCommandBuilder<T> | MessageCommandBuilder<T>;
|
|
9
9
|
/**
|
|
10
10
|
* Any command data
|
|
11
11
|
*/
|
|
12
|
-
export declare type AnyCommandData<T
|
|
12
|
+
export declare type AnyCommandData<T = unknown> = SlashCommandData<T> | MessageCommandData<T>;
|
|
13
13
|
/**
|
|
14
14
|
* Any slash command builders
|
|
15
15
|
*/
|
|
16
|
-
export declare type AnySlashCommandBuilder<T
|
|
16
|
+
export declare type AnySlashCommandBuilder<T = unknown> = SlashCommandBuilder<T> | SlashCommandOptionsOnlyBuilder<T> | SlashCommandSubcommandsOnlyBuilder<T>;
|
|
17
17
|
/**
|
|
18
18
|
* Any command halt functions
|
|
19
19
|
*/
|
|
20
|
-
export declare type AnyCommandHaltFunction = SlashCommandHaltFunction | MessageCommandHaltFunction
|
|
20
|
+
export declare type AnyCommandHaltFunction<T = unknown> = SlashCommandHaltFunction<T> | MessageCommandHaltFunction<T>;
|
|
21
21
|
/**
|
|
22
22
|
* Any command execute function
|
|
23
23
|
*/
|
|
24
|
-
export declare type AnyCommandExecuteFunction = SlashCommandExecuteFunction | MessageCommandExecuteFunction
|
|
24
|
+
export declare type AnyCommandExecuteFunction<T = unknown> = SlashCommandExecuteFunction<T> | MessageCommandExecuteFunction<T>;
|
|
25
25
|
/**
|
|
26
26
|
* Command halt function
|
|
27
27
|
*/
|
|
28
|
-
export declare type CommandHaltFunction<T extends CommandBuilderType> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData : MessageCommandHaltData) => Awaitable<boolean | null | undefined | void>;
|
|
28
|
+
export declare type CommandHaltFunction<T extends CommandBuilderType, M = unknown> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData<M> : T extends CommandBuilderType.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 CommandBuilderType> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : MessageCommandExecuteData) => Awaitable<void>;
|
|
32
|
+
export declare type CommandExecuteFunction<T extends CommandBuilderType, M = unknown> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData<M> : SlashCommandExecuteData<M> | MessageCommandExecuteData<M>) => Awaitable<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Message command options resolvable
|
|
35
35
|
*/
|
|
@@ -60,13 +60,13 @@ export declare enum CommandBuilderType {
|
|
|
60
60
|
/**
|
|
61
61
|
* Shared command builder methods and properties
|
|
62
62
|
*/
|
|
63
|
-
export interface SharedCommandBuilderProperties<T
|
|
63
|
+
export interface SharedCommandBuilderProperties<T = unknown> {
|
|
64
64
|
readonly type: CommandBuilderType;
|
|
65
65
|
cooldown: number;
|
|
66
66
|
requiredBotPermissions: PermissionResolvable[];
|
|
67
67
|
requiredMemberPermissions: PermissionResolvable[];
|
|
68
|
-
halt?: AnyCommandHaltFunction
|
|
69
|
-
execute: AnyCommandExecuteFunction
|
|
68
|
+
halt?: AnyCommandHaltFunction<T>;
|
|
69
|
+
execute: AnyCommandExecuteFunction<T>;
|
|
70
70
|
metadata?: T;
|
|
71
71
|
/**
|
|
72
72
|
* Sets the execute cooldown for this command.
|
|
@@ -110,7 +110,7 @@ export interface SharedCommandDataProperties {
|
|
|
110
110
|
/**
|
|
111
111
|
* Slash command object data interface
|
|
112
112
|
*/
|
|
113
|
-
export interface SlashCommandData<T
|
|
113
|
+
export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
|
|
114
114
|
type: CommandBuilderType.SlashCommand;
|
|
115
115
|
nameLocalizations?: LocalizationMap;
|
|
116
116
|
descriptionLocalizations?: LocalizationMap;
|
|
@@ -121,8 +121,8 @@ export interface SlashCommandData<T extends unknown = any> extends SharedCommand
|
|
|
121
121
|
defaultPermission?: boolean;
|
|
122
122
|
defaultMemberPermissions?: string | null;
|
|
123
123
|
dmPermission?: boolean;
|
|
124
|
-
halt?: SlashCommandHaltFunction
|
|
125
|
-
execute: SlashCommandExecuteFunction
|
|
124
|
+
halt?: SlashCommandHaltFunction<T>;
|
|
125
|
+
execute: SlashCommandExecuteFunction<T>;
|
|
126
126
|
}
|
|
127
127
|
export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
|
|
128
128
|
choices?: {
|
|
@@ -178,14 +178,14 @@ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProper
|
|
|
178
178
|
/**
|
|
179
179
|
* Message command object data interface
|
|
180
180
|
*/
|
|
181
|
-
export interface MessageCommandData<T
|
|
181
|
+
export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
|
|
182
182
|
type: CommandBuilderType.MessageCommand;
|
|
183
183
|
aliases?: string[];
|
|
184
184
|
validateOptions?: boolean;
|
|
185
185
|
allowExecuteInDM?: boolean;
|
|
186
186
|
allowExecuteByBots?: boolean;
|
|
187
|
-
halt?: MessageCommandHaltFunction
|
|
188
|
-
execute: MessageCommandExecuteFunction
|
|
187
|
+
halt?: MessageCommandHaltFunction<T>;
|
|
188
|
+
execute: MessageCommandExecuteFunction<T>;
|
|
189
189
|
options?: MessageCommandOptionResolvable[];
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -7,46 +7,65 @@ import { CommandBuilderType } from '../types/builders';
|
|
|
7
7
|
/**
|
|
8
8
|
* Any command halt data
|
|
9
9
|
*/
|
|
10
|
-
export declare type AnyCommandHaltData = SlashCommandHaltData | MessageCommandHaltData
|
|
10
|
+
export declare type AnyCommandHaltData<T = unknown> = SlashCommandHaltData<T> | MessageCommandHaltData<T>;
|
|
11
11
|
/**
|
|
12
12
|
* command halt data
|
|
13
13
|
*/
|
|
14
|
-
export declare type CommandHaltData<T extends CommandBuilderType> = CommandErrorData<T> | CommandCooldownData<T> | (T extends CommandBuilderType.SlashCommand ? never : CommandInvalidArguments<T> | CommandMissingArguments<T>) | CommandMissingMemberPermissions<T> | CommandMissingBotPermissions<T>;
|
|
14
|
+
export declare type CommandHaltData<T extends CommandBuilderType, M = unknown> = CommandErrorData<T, M> | CommandCooldownData<T, M> | (T extends CommandBuilderType.SlashCommand ? never : CommandInvalidArguments<T, M> | CommandMissingArguments<T, M>) | CommandMissingMemberPermissions<T, M> | CommandMissingBotPermissions<T, M>;
|
|
15
15
|
/**
|
|
16
16
|
* Any command execute data
|
|
17
17
|
*/
|
|
18
|
-
export declare type AnyCommandExecuteData = SlashCommandExecuteData | MessageCommandExecuteData
|
|
18
|
+
export declare type AnyCommandExecuteData<T = unknown> = SlashCommandExecuteData<T> | MessageCommandExecuteData<T>;
|
|
19
19
|
/**
|
|
20
20
|
* Command execute data
|
|
21
21
|
*/
|
|
22
22
|
export interface BaseCommandExecuteData {
|
|
23
|
+
/**
|
|
24
|
+
* Bot client
|
|
25
|
+
*/
|
|
23
26
|
client: RecipleClient<true>;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Command halt reason base
|
|
27
30
|
*/
|
|
28
|
-
export interface BaseCommandHaltData<T extends CommandBuilderType> {
|
|
29
|
-
|
|
31
|
+
export interface BaseCommandHaltData<T extends CommandBuilderType, M = unknown> {
|
|
32
|
+
/**
|
|
33
|
+
* Halt reason
|
|
34
|
+
*/
|
|
35
|
+
reason: CommandHaltReason;
|
|
36
|
+
/**
|
|
37
|
+
* Command execute da6a
|
|
38
|
+
*/
|
|
39
|
+
executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData<M> : AnyCommandExecuteData<M>;
|
|
30
40
|
}
|
|
31
|
-
export interface CommandErrorData<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
41
|
+
export interface CommandErrorData<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
32
42
|
reason: CommandHaltReason.Error;
|
|
43
|
+
/**
|
|
44
|
+
* Caught error
|
|
45
|
+
*/
|
|
33
46
|
error: any;
|
|
34
47
|
}
|
|
35
|
-
export interface CommandCooldownData<T extends CommandBuilderType> extends BaseCommandHaltData<T>, CooledDownUser {
|
|
48
|
+
export interface CommandCooldownData<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M>, CooledDownUser {
|
|
36
49
|
reason: CommandHaltReason.Cooldown;
|
|
37
50
|
}
|
|
38
|
-
export interface CommandInvalidArguments<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
51
|
+
export interface CommandInvalidArguments<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
39
52
|
reason: CommandHaltReason.InvalidArguments;
|
|
53
|
+
/**
|
|
54
|
+
* Arguments that are invalid
|
|
55
|
+
*/
|
|
40
56
|
invalidArguments: MessageCommandOptionManager;
|
|
41
57
|
}
|
|
42
|
-
export interface CommandMissingArguments<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
58
|
+
export interface CommandMissingArguments<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
43
59
|
reason: CommandHaltReason.MissingArguments;
|
|
60
|
+
/**
|
|
61
|
+
* Arguments that are missing
|
|
62
|
+
*/
|
|
44
63
|
missingArguments: MessageCommandOptionManager;
|
|
45
64
|
}
|
|
46
|
-
export interface CommandMissingMemberPermissions<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
65
|
+
export interface CommandMissingMemberPermissions<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
47
66
|
reason: CommandHaltReason.MissingMemberPermissions;
|
|
48
67
|
}
|
|
49
|
-
export interface CommandMissingBotPermissions<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
68
|
+
export interface CommandMissingBotPermissions<T extends CommandBuilderType, M = unknown> extends BaseCommandHaltData<T, M> {
|
|
50
69
|
reason: CommandHaltReason.MissingBotPermissions;
|
|
51
70
|
}
|
|
52
71
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ApplicationCommandBuilder } from '../registerApplicationCommands';
|
|
2
2
|
import { ApplicationCommandData, PermissionsBitField } from 'discord.js';
|
|
3
|
+
import { ConfigCommandPermissions } from '../classes/RecipleConfig';
|
|
3
4
|
import { RecipleModule, RecipleScript } from '../modules';
|
|
4
5
|
import { RecipleClient } from '../classes/RecipleClient';
|
|
5
|
-
import { Config } from '../classes/RecipleConfig';
|
|
6
6
|
import { AnyCommandBuilder } from './builders';
|
|
7
7
|
export interface RecipleClientAddModuleOptions {
|
|
8
8
|
/**
|
|
@@ -33,7 +33,19 @@ export interface RegisterApplicationCommandsOptions {
|
|
|
33
33
|
guilds?: string | string[];
|
|
34
34
|
}
|
|
35
35
|
export interface UserHasCommandPermissionsOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Command builder
|
|
38
|
+
*/
|
|
36
39
|
builder: AnyCommandBuilder;
|
|
40
|
+
/**
|
|
41
|
+
* Member permissions
|
|
42
|
+
*/
|
|
37
43
|
memberPermissions?: PermissionsBitField;
|
|
38
|
-
|
|
44
|
+
/***
|
|
45
|
+
* Required command config permissions
|
|
46
|
+
*/
|
|
47
|
+
commandPermissions?: {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
commands: ConfigCommandPermissions[];
|
|
50
|
+
};
|
|
39
51
|
}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Check if an object is a class
|
|
3
|
+
* @param object Object to identify
|
|
4
|
+
*/
|
|
5
|
+
export declare function isClass<T = any>(object: any): object is T;
|
|
6
|
+
/**
|
|
7
|
+
* Emit process warning about deprecated method/function
|
|
8
|
+
* @param content Warning content
|
|
9
|
+
*/
|
|
10
|
+
export declare function deprecationWarning(content: string | Error): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"bin": "dist/cjs/bin.js",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"keywords": [
|
|
12
12
|
"Discord",
|
|
13
13
|
"Discord.js handler",
|
|
14
|
-
"Reciple"
|
|
14
|
+
"Reciple",
|
|
15
|
+
"Slash command handler",
|
|
16
|
+
"Message command handler"
|
|
15
17
|
],
|
|
16
18
|
"contributors": [
|
|
17
19
|
"GhexterCortes"
|
|
@@ -47,14 +49,14 @@
|
|
|
47
49
|
"chalk": "4.1.2",
|
|
48
50
|
"commander": "^9.4.1",
|
|
49
51
|
"dotenv": "^16.0.3",
|
|
50
|
-
"fallout-utility": "^1.5.
|
|
51
|
-
"semver": "^7.3.
|
|
52
|
+
"fallout-utility": "^1.5.2",
|
|
53
|
+
"semver": "^7.3.8",
|
|
52
54
|
"wildcard-match": "^5.1.2",
|
|
53
|
-
"yaml": "^2.1.
|
|
55
|
+
"yaml": "^2.1.3"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@discordjs/docgen": "^0.12.1",
|
|
57
|
-
"@types/node": "^18.
|
|
59
|
+
"@types/node": "^18.8.3",
|
|
58
60
|
"@types/semver": "^7.3.12",
|
|
59
61
|
"discord.js": "^14.5.0",
|
|
60
62
|
"rimraf": "^3.0.2",
|