reciple 5.4.3 → 5.5.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/README.md +3 -8
- package/{bin → dist/cjs}/bin.js +0 -0
- package/{bin → dist/cjs}/index.js +0 -0
- package/{bin → dist/cjs}/reciple/classes/CommandCooldownManager.js +0 -0
- package/{bin → dist/cjs}/reciple/classes/MessageCommandOptionManager.js +0 -0
- package/{bin → dist/cjs}/reciple/classes/RecipleClient.js +16 -15
- package/{bin → dist/cjs}/reciple/classes/RecipleConfig.js +3 -3
- package/{bin → dist/cjs}/reciple/classes/builders/MessageCommandBuilder.js +21 -15
- package/{bin → dist/cjs}/reciple/classes/builders/MessageCommandOptionBuilder.js +4 -4
- package/{bin → dist/cjs}/reciple/classes/builders/SlashCommandBuilder.js +13 -6
- package/{bin → dist/cjs}/reciple/flags.js +0 -0
- package/{bin → dist/cjs}/reciple/logger.js +0 -0
- package/{bin → dist/cjs}/reciple/modules.js +0 -0
- package/{bin → dist/cjs}/reciple/permissions.js +0 -0
- package/{bin → dist/cjs}/reciple/registerApplicationCommands.js +1 -1
- package/{bin → dist/cjs}/reciple/types/builders.js +0 -0
- package/{bin → dist/cjs}/reciple/types/commands.js +0 -0
- package/{bin → dist/cjs}/reciple/types/paramOptions.js +0 -0
- package/{bin → dist/cjs}/reciple/util.js +0 -0
- package/{bin → dist/cjs}/reciple/version.js +2 -2
- package/{bin → dist/types}/bin.d.ts +0 -0
- package/{bin → dist/types}/index.d.ts +0 -0
- package/{bin → dist/types}/reciple/classes/CommandCooldownManager.d.ts +0 -0
- package/{bin → dist/types}/reciple/classes/MessageCommandOptionManager.d.ts +0 -0
- package/{bin → dist/types}/reciple/classes/RecipleClient.d.ts +3 -7
- package/{bin → dist/types}/reciple/classes/RecipleConfig.d.ts +1 -0
- package/{bin → dist/types}/reciple/classes/builders/MessageCommandBuilder.d.ts +9 -7
- package/{bin → dist/types}/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +0 -0
- package/{bin → dist/types}/reciple/classes/builders/SlashCommandBuilder.d.ts +11 -9
- package/{bin → dist/types}/reciple/flags.d.ts +0 -0
- package/{bin → dist/types}/reciple/logger.d.ts +0 -0
- package/{bin → dist/types}/reciple/modules.d.ts +0 -0
- package/{bin → dist/types}/reciple/permissions.d.ts +1 -1
- package/{bin → dist/types}/reciple/registerApplicationCommands.d.ts +0 -0
- package/{bin → dist/types}/reciple/types/builders.d.ts +16 -12
- package/{bin → dist/types}/reciple/types/commands.d.ts +0 -0
- package/{bin → dist/types}/reciple/types/paramOptions.d.ts +0 -0
- package/{bin → dist/types}/reciple/util.d.ts +0 -0
- package/{bin → dist/types}/reciple/version.d.ts +0 -0
- package/docs/README.md +1 -0
- package/package.json +17 -19
- package/resource/reciple.yml +2 -0
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ npx reciple
|
|
|
107
107
|
|
|
108
108
|
## MessageCommandBuilder Example
|
|
109
109
|
|
|
110
|
-
* Read docs for [
|
|
110
|
+
* Read docs for [MessageCommandBuilder](https://reciple.js.org/#/docs/reciple.js/main/class/MessageCommandBuilder)
|
|
111
111
|
|
|
112
112
|
```js
|
|
113
113
|
new MessageCommandBuilder()
|
|
@@ -119,9 +119,7 @@ new MessageCommandBuilder()
|
|
|
119
119
|
|
|
120
120
|
## Built-in message command validation
|
|
121
121
|
|
|
122
|
-
* Read docs for [
|
|
123
|
-
* Read docs for [`MessageCommandOptionBuilder`](https://reciple.js.org/classes/MessageCommandOptionBuilder.html)
|
|
124
|
-
* Read docs for [`MessageCommandOptionManager`](https://reciple.js.org/classes/MessageCommandOptionManager.html)
|
|
122
|
+
* Read docs for [MessageCommandBuilder#setValidateOptions()](https://reciple.js.org/#/docs/reciple.js/main/class/MessageCommandBuilder?scrollTo=setValidateOptions), [MessageCommandOptionBuilder](https://reciple.js.org/#/docs/reciple.js/main/class/MessageCommandOptionBuilder), [MessageCommandOptionManager](https://reciple.js.org/#/docs/reciple.js/main/class/MessageCommandOptionManager)
|
|
125
123
|
```js
|
|
126
124
|
new MessageCommandBuilder()
|
|
127
125
|
.setName("command")
|
|
@@ -143,10 +141,7 @@ new MessageCommandBuilder()
|
|
|
143
141
|
|
|
144
142
|
## Command Cooldowns
|
|
145
143
|
|
|
146
|
-
* Read docs for [
|
|
147
|
-
* Read docs for [`MessageCommandBuilder#setCooldown()`](https://reciple.js.org/classes/MessageCommandBuilder.html#setCooldown)
|
|
148
|
-
* Read docs for [`CommandHaltReason`](https://reciple.js.org/enums/CommandHaltReason.html)
|
|
149
|
-
* Read docs for [`CommandCooldownData`](https://reciple.js.org/interfaces/CommandCooldownData.html)
|
|
144
|
+
* Read docs for [SlashCommandBuilder#setCooldown()](https://reciple.js.org/#/docs/reciple.js/main/class/SlashCommandBuilder?scrollTo=setCooldown), [MessageCommandBuilder#setCooldown()](https://reciple.js.org/#/docs/reciple.js/main/class/MessageCommandBuilder?scrollTo=setCooldown), [CommandHaltReason](https://reciple.js.org/#/docs/reciple.js/main/typedef/CommandHaltReason), [CommandCooldownData](https://reciple.js.org/#/docs/reciple.js/main/typedef/CommandCooldownData)
|
|
150
145
|
|
|
151
146
|
```js
|
|
152
147
|
// Slash command
|
package/{bin → dist/cjs}/bin.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -21,18 +21,17 @@ const flags_1 = require("../flags");
|
|
|
21
21
|
const path_1 = __importDefault(require("path"));
|
|
22
22
|
const discord_js_1 = require("discord.js");
|
|
23
23
|
class RecipleClient extends discord_js_1.Client {
|
|
24
|
-
config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
|
|
25
|
-
commands = { slashCommands: {}, messageCommands: {} };
|
|
26
|
-
additionalApplicationCommands = [];
|
|
27
|
-
cooldowns = new CommandCooldownManager_1.CommandCooldownManager();
|
|
28
|
-
modules = [];
|
|
29
|
-
logger;
|
|
30
|
-
version = version_1.version;
|
|
31
24
|
/**
|
|
32
25
|
* @param options Client options
|
|
33
26
|
*/
|
|
34
27
|
constructor(options) {
|
|
35
28
|
super(options);
|
|
29
|
+
this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
|
|
30
|
+
this.commands = { slashCommands: new discord_js_1.Collection(), messageCommands: new discord_js_1.Collection() };
|
|
31
|
+
this.additionalApplicationCommands = [];
|
|
32
|
+
this.cooldowns = new CommandCooldownManager_1.CommandCooldownManager();
|
|
33
|
+
this.modules = [];
|
|
34
|
+
this.version = version_1.version;
|
|
36
35
|
this.logger = (0, logger_1.createLogger)(!!options.config?.fileLogging.stringifyLoggedJSON, options.config?.fileLogging.debugmode);
|
|
37
36
|
if (!options.config)
|
|
38
37
|
throw new Error('Config is not defined.');
|
|
@@ -133,10 +132,10 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
133
132
|
*/
|
|
134
133
|
addCommand(command) {
|
|
135
134
|
if (command.type === builders_1.CommandBuilderType.SlashCommand) {
|
|
136
|
-
this.commands.slashCommands
|
|
135
|
+
this.commands.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
|
|
137
136
|
}
|
|
138
137
|
else if (command.type === builders_1.CommandBuilderType.MessageCommand) {
|
|
139
|
-
this.commands.messageCommands
|
|
138
|
+
this.commands.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
|
|
140
139
|
}
|
|
141
140
|
else if (this.isClientLogsEnabled()) {
|
|
142
141
|
this.logger.error(`Unknow command "${typeof command ?? 'unknown'}".`);
|
|
@@ -160,6 +159,8 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
160
159
|
async slashCommandExecute(interaction) {
|
|
161
160
|
if (!interaction || !interaction.isChatInputCommand() || !this.isReady())
|
|
162
161
|
return;
|
|
162
|
+
if (!this.config.commands.slashCommand.acceptRepliedInteractions && (interaction.replied || interaction.deferred))
|
|
163
|
+
return;
|
|
163
164
|
const command = this.findCommand(interaction.commandName, builders_1.CommandBuilderType.SlashCommand);
|
|
164
165
|
if (!command)
|
|
165
166
|
return;
|
|
@@ -285,11 +286,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
285
286
|
findCommand(command, type) {
|
|
286
287
|
switch (type) {
|
|
287
288
|
case builders_1.CommandBuilderType.SlashCommand:
|
|
288
|
-
return this.commands.slashCommands
|
|
289
|
+
return this.commands.slashCommands.get(command);
|
|
289
290
|
case builders_1.CommandBuilderType.MessageCommand:
|
|
290
|
-
return this.commands.messageCommands
|
|
291
|
+
return this.commands.messageCommands.get(command.toLowerCase())
|
|
291
292
|
?? (this.config.commands.messageCommand.allowCommandAlias
|
|
292
|
-
?
|
|
293
|
+
? this.commands.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase()))
|
|
293
294
|
: undefined);
|
|
294
295
|
default:
|
|
295
296
|
throw new TypeError('Unknown command type');
|
|
@@ -338,9 +339,9 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
338
339
|
return executeData;
|
|
339
340
|
}
|
|
340
341
|
catch (err) {
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
if (await this._haltCommand(command, { executeData: executeData, reason: commands_1.CommandHaltReason.Error, error: err }))
|
|
343
|
+
return;
|
|
344
|
+
await this._commandExecuteError(err, executeData);
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
347
|
/**
|
|
@@ -14,13 +14,12 @@ const yaml_1 = __importDefault(require("yaml"));
|
|
|
14
14
|
* Create/parse reciple config
|
|
15
15
|
*/
|
|
16
16
|
class RecipleConfig {
|
|
17
|
-
config = RecipleConfig.getDefaultConfig();
|
|
18
|
-
configPath = path_1.default.join(flags_1.cwd, 'reciple.yml');
|
|
19
|
-
static defaultConfigPath = path_1.default.join(__dirname, '../../../resource/reciple.yml');
|
|
20
17
|
/**
|
|
21
18
|
* @param configPath Path to config
|
|
22
19
|
*/
|
|
23
20
|
constructor(configPath) {
|
|
21
|
+
this.config = RecipleConfig.getDefaultConfig();
|
|
22
|
+
this.configPath = path_1.default.join(flags_1.cwd, 'reciple.yml');
|
|
24
23
|
if (!configPath)
|
|
25
24
|
throw new Error('Config path is not defined');
|
|
26
25
|
this.configPath = configPath;
|
|
@@ -97,3 +96,4 @@ class RecipleConfig {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
exports.RecipleConfig = RecipleConfig;
|
|
99
|
+
RecipleConfig.defaultConfigPath = path_1.default.join(__dirname, '../../../../resource/reciple.yml');
|
|
@@ -9,24 +9,25 @@ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
|
9
9
|
* Reciple builder for message command
|
|
10
10
|
*/
|
|
11
11
|
class MessageCommandBuilder {
|
|
12
|
-
type = builders_1.CommandBuilderType.MessageCommand;
|
|
13
|
-
name = '';
|
|
14
|
-
description = '';
|
|
15
|
-
cooldown = 0;
|
|
16
|
-
aliases = [];
|
|
17
|
-
validateOptions = false;
|
|
18
|
-
options = [];
|
|
19
|
-
requiredBotPermissions = [];
|
|
20
|
-
requiredMemberPermissions = [];
|
|
21
|
-
allowExecuteInDM = true;
|
|
22
|
-
allowExecuteByBots = false;
|
|
23
|
-
halt;
|
|
24
|
-
execute = () => { };
|
|
25
12
|
constructor(data) {
|
|
13
|
+
this.type = builders_1.CommandBuilderType.MessageCommand;
|
|
14
|
+
this.name = '';
|
|
15
|
+
this.description = '';
|
|
16
|
+
this.cooldown = 0;
|
|
17
|
+
this.aliases = [];
|
|
18
|
+
this.validateOptions = false;
|
|
19
|
+
this.options = [];
|
|
20
|
+
this.requiredBotPermissions = [];
|
|
21
|
+
this.requiredMemberPermissions = [];
|
|
22
|
+
this.allowExecuteInDM = true;
|
|
23
|
+
this.allowExecuteByBots = false;
|
|
24
|
+
this.execute = () => { };
|
|
26
25
|
if (data?.name !== undefined)
|
|
27
26
|
this.setName(data.name);
|
|
28
27
|
if (data?.description !== undefined)
|
|
29
28
|
this.setDescription(data.description);
|
|
29
|
+
if (data?.aliases !== undefined)
|
|
30
|
+
this.addAliases(data.aliases);
|
|
30
31
|
if (data?.cooldown !== undefined)
|
|
31
32
|
this.setCooldown(Number(data?.cooldown));
|
|
32
33
|
if (data?.requiredBotPermissions !== undefined)
|
|
@@ -37,8 +38,8 @@ class MessageCommandBuilder {
|
|
|
37
38
|
this.setHalt(data.halt);
|
|
38
39
|
if (data?.execute !== undefined)
|
|
39
40
|
this.setExecute(data.execute);
|
|
40
|
-
if (data?.
|
|
41
|
-
this.
|
|
41
|
+
if (data?.metadata !== undefined)
|
|
42
|
+
this.setMetadata(data.metadata);
|
|
42
43
|
if (data?.allowExecuteByBots !== undefined)
|
|
43
44
|
this.setAllowExecuteByBots(true);
|
|
44
45
|
if (data?.allowExecuteInDM !== undefined)
|
|
@@ -150,6 +151,10 @@ class MessageCommandBuilder {
|
|
|
150
151
|
this.execute = execute;
|
|
151
152
|
return this;
|
|
152
153
|
}
|
|
154
|
+
setMetadata(metadata) {
|
|
155
|
+
this.metadata = metadata;
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
153
158
|
/**
|
|
154
159
|
* Returns JSON object of this builder
|
|
155
160
|
*/
|
|
@@ -164,6 +169,7 @@ class MessageCommandBuilder {
|
|
|
164
169
|
requiredMemberPermissions: this.requiredMemberPermissions,
|
|
165
170
|
halt: this.halt,
|
|
166
171
|
execute: this.execute,
|
|
172
|
+
metadata: this.metadata,
|
|
167
173
|
allowExecuteByBots: this.allowExecuteByBots,
|
|
168
174
|
allowExecuteInDM: this.allowExecuteInDM,
|
|
169
175
|
validateOptions: this.validateOptions,
|
|
@@ -5,11 +5,11 @@ exports.MessageCommandOptionBuilder = void 0;
|
|
|
5
5
|
* Option builder for MessageCommandBuilder
|
|
6
6
|
*/
|
|
7
7
|
class MessageCommandOptionBuilder {
|
|
8
|
-
name = '';
|
|
9
|
-
description = '';
|
|
10
|
-
required = false;
|
|
11
|
-
validator = () => true;
|
|
12
8
|
constructor(data) {
|
|
9
|
+
this.name = '';
|
|
10
|
+
this.description = '';
|
|
11
|
+
this.required = false;
|
|
12
|
+
this.validator = () => true;
|
|
13
13
|
if (data?.name !== undefined)
|
|
14
14
|
this.setName(data.name);
|
|
15
15
|
if (data?.description !== undefined)
|
|
@@ -8,14 +8,14 @@ const discord_js_1 = require("discord.js");
|
|
|
8
8
|
* Reciple builder for slash command
|
|
9
9
|
*/
|
|
10
10
|
class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
11
|
-
type = builders_1.CommandBuilderType.SlashCommand;
|
|
12
|
-
cooldown = 0;
|
|
13
|
-
requiredBotPermissions = [];
|
|
14
|
-
requiredMemberPermissions = [];
|
|
15
|
-
halt;
|
|
16
|
-
execute = () => { };
|
|
17
11
|
constructor(data) {
|
|
18
12
|
super();
|
|
13
|
+
this.type = builders_1.CommandBuilderType.SlashCommand;
|
|
14
|
+
this.cooldown = 0;
|
|
15
|
+
this.requiredBotPermissions = [];
|
|
16
|
+
this.requiredMemberPermissions = [];
|
|
17
|
+
this.execute = () => { };
|
|
18
|
+
// TODO: WTH
|
|
19
19
|
if (data?.name !== undefined)
|
|
20
20
|
this.setName(data.name);
|
|
21
21
|
if (data?.description !== undefined)
|
|
@@ -30,6 +30,8 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
30
30
|
this.setHalt(data.halt);
|
|
31
31
|
if (data?.execute !== undefined)
|
|
32
32
|
this.setExecute(data.execute);
|
|
33
|
+
if (data?.metadata !== undefined)
|
|
34
|
+
this.setMetadata(data.metadata);
|
|
33
35
|
if (data?.nameLocalizations !== undefined)
|
|
34
36
|
this.setNameLocalizations(data.nameLocalizations);
|
|
35
37
|
if (data?.descriptionLocalizations !== undefined)
|
|
@@ -68,6 +70,10 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
68
70
|
this.execute = execute;
|
|
69
71
|
return this;
|
|
70
72
|
}
|
|
73
|
+
setMetadata(metadata) {
|
|
74
|
+
this.metadata = metadata;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
71
77
|
/**
|
|
72
78
|
* Add option builder to command builder
|
|
73
79
|
*/
|
|
@@ -114,6 +120,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
114
120
|
*/
|
|
115
121
|
static resolveOption(option) {
|
|
116
122
|
let builder;
|
|
123
|
+
// TODO: I can do better than this
|
|
117
124
|
switch (option.type) {
|
|
118
125
|
case discord_js_1.ApplicationCommandOptionType.Attachment:
|
|
119
126
|
builder = new discord_js_1.SlashCommandAttachmentOption();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -23,7 +23,7 @@ async function registerApplicationCommands(options) {
|
|
|
23
23
|
if (client.isClientLogsEnabled())
|
|
24
24
|
client.logger.debug(`Set required permissions for ${cmd.name}`);
|
|
25
25
|
}
|
|
26
|
-
client.commands.slashCommands
|
|
26
|
+
client.commands.slashCommands.set(cmd.name, cmd);
|
|
27
27
|
}
|
|
28
28
|
return cmd.toJSON();
|
|
29
29
|
}) ?? [];
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,11 +8,11 @@ const semver_1 = __importDefault(require("semver"));
|
|
|
8
8
|
/**
|
|
9
9
|
* Current reciple version
|
|
10
10
|
*/
|
|
11
|
-
exports.version = `${semver_1.default.coerce(require('
|
|
11
|
+
exports.version = `${semver_1.default.coerce(require('../../../package.json').version)}`;
|
|
12
12
|
/**
|
|
13
13
|
* Current reciple version from package.json
|
|
14
14
|
*/
|
|
15
|
-
exports.rawVersion = require('
|
|
15
|
+
exports.rawVersion = require('../../../package.json').version;
|
|
16
16
|
/**
|
|
17
17
|
* Check if the version is valid
|
|
18
18
|
* @param ver Version string to validated
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,7 +8,7 @@ import { RecipleClientAddModuleOptions } from '../types/paramOptions';
|
|
|
8
8
|
import { Logger as ILogger } from 'fallout-utility';
|
|
9
9
|
import { Config } from './RecipleConfig';
|
|
10
10
|
import { RecipleModule } from '../modules';
|
|
11
|
-
import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message, RestOrArray } from 'discord.js';
|
|
11
|
+
import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Collection, Interaction, Message, RestOrArray } from 'discord.js';
|
|
12
12
|
/**
|
|
13
13
|
* Options for Reciple client
|
|
14
14
|
*/
|
|
@@ -19,12 +19,8 @@ export interface RecipleClientOptions extends ClientOptions {
|
|
|
19
19
|
* Reciple client commands
|
|
20
20
|
*/
|
|
21
21
|
export interface RecipleClientCommands {
|
|
22
|
-
slashCommands:
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
messageCommands: {
|
|
26
|
-
[commandName: string]: MessageCommandBuilder;
|
|
27
|
-
};
|
|
22
|
+
slashCommands: Collection<string, AnySlashCommandBuilder>;
|
|
23
|
+
messageCommands: Collection<string, MessageCommandBuilder>;
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
26
|
* Reciple client events
|
|
@@ -7,11 +7,11 @@ import { Command as CommandMessage } from 'fallout-utility';
|
|
|
7
7
|
/**
|
|
8
8
|
* Execute data for message command
|
|
9
9
|
*/
|
|
10
|
-
export interface MessageCommandExecuteData extends BaseCommandExecuteData {
|
|
10
|
+
export interface MessageCommandExecuteData<T extends unknown = any> extends BaseCommandExecuteData {
|
|
11
11
|
message: Message;
|
|
12
12
|
options: MessageCommandOptionManager;
|
|
13
13
|
command: CommandMessage;
|
|
14
|
-
builder: MessageCommandBuilder
|
|
14
|
+
builder: MessageCommandBuilder<T>;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Validated message command option
|
|
@@ -38,7 +38,7 @@ export declare type MessageCommandExecuteFunction = CommandExecuteFunction<Comma
|
|
|
38
38
|
/**
|
|
39
39
|
* Reciple builder for message command
|
|
40
40
|
*/
|
|
41
|
-
export declare class MessageCommandBuilder implements SharedCommandBuilderProperties {
|
|
41
|
+
export declare class MessageCommandBuilder<T extends unknown = any> implements SharedCommandBuilderProperties<T> {
|
|
42
42
|
readonly type = CommandBuilderType.MessageCommand;
|
|
43
43
|
name: string;
|
|
44
44
|
description: string;
|
|
@@ -52,7 +52,8 @@ export declare class MessageCommandBuilder implements SharedCommandBuilderProper
|
|
|
52
52
|
allowExecuteByBots: boolean;
|
|
53
53
|
halt?: MessageCommandHaltFunction;
|
|
54
54
|
execute: MessageCommandExecuteFunction;
|
|
55
|
-
|
|
55
|
+
metadata?: T;
|
|
56
|
+
constructor(data?: Partial<Omit<MessageCommandData<T>, "type">>);
|
|
56
57
|
/**
|
|
57
58
|
* Sets the command name
|
|
58
59
|
* @param name Command name
|
|
@@ -93,15 +94,16 @@ export declare class MessageCommandBuilder implements SharedCommandBuilderProper
|
|
|
93
94
|
setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
94
95
|
setHalt(halt?: MessageCommandHaltFunction | null): this;
|
|
95
96
|
setExecute(execute: MessageCommandExecuteFunction): this;
|
|
97
|
+
setMetadata(metadata?: T): this;
|
|
96
98
|
/**
|
|
97
99
|
* Returns JSON object of this builder
|
|
98
100
|
*/
|
|
99
|
-
toJSON(): MessageCommandData
|
|
100
|
-
static resolveMessageCommand(commandData: MessageCommandData | MessageCommandBuilder): MessageCommandBuilder
|
|
101
|
+
toJSON(): MessageCommandData<T>;
|
|
102
|
+
static resolveMessageCommand<T extends unknown = any>(commandData: MessageCommandData<T> | MessageCommandBuilder<T>): MessageCommandBuilder<T>;
|
|
101
103
|
/**
|
|
102
104
|
* Is a message command builder
|
|
103
105
|
*/
|
|
104
|
-
static isMessageCommandBuilder(builder: unknown): builder is MessageCommandBuilder
|
|
106
|
+
static isMessageCommandBuilder<T>(builder: unknown): builder is MessageCommandBuilder<T>;
|
|
105
107
|
/**
|
|
106
108
|
* Is a message command execute data
|
|
107
109
|
*/
|
|
File without changes
|
|
@@ -4,9 +4,9 @@ import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCo
|
|
|
4
4
|
/**
|
|
5
5
|
* Execute data for slash command
|
|
6
6
|
*/
|
|
7
|
-
export interface SlashCommandExecuteData extends BaseCommandExecuteData {
|
|
7
|
+
export interface SlashCommandExecuteData<T extends unknown = any> extends BaseCommandExecuteData {
|
|
8
8
|
interaction: ChatInputCommandInteraction;
|
|
9
|
-
builder: AnySlashCommandBuilder
|
|
9
|
+
builder: AnySlashCommandBuilder<T>;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Slash command halt data
|
|
@@ -20,9 +20,9 @@ export declare type SlashCommandHaltFunction = CommandHaltFunction<CommandBuilde
|
|
|
20
20
|
* Slash command execute function
|
|
21
21
|
*/
|
|
22
22
|
export declare type SlashCommandExecuteFunction = CommandExecuteFunction<CommandBuilderType.SlashCommand>;
|
|
23
|
-
export declare type SlashCommandSubcommandsOnlyBuilder = Omit<SlashCommandBuilder
|
|
24
|
-
export declare type SlashCommandOptionsOnlyBuilder = Omit<SlashCommandBuilder
|
|
25
|
-
export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
|
|
23
|
+
export declare type SlashCommandSubcommandsOnlyBuilder<T extends unknown = any> = Omit<SlashCommandBuilder<T>, "addBooleanOption" | "addUserOption" | "addChannelOption" | "addRoleOption" | "addAttachmentOption" | "addMentionableOption" | "addStringOption" | "addIntegerOption" | "addNumberOption">;
|
|
24
|
+
export declare type SlashCommandOptionsOnlyBuilder<T extends unknown = any> = Omit<SlashCommandBuilder<T>, "addSubcommand" | "addSubcommandGroup">;
|
|
25
|
+
export interface SlashCommandBuilder<T extends unknown = any> extends DiscordJsSlashCommandBuilder {
|
|
26
26
|
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
|
27
27
|
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
|
28
28
|
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
|
|
@@ -38,19 +38,21 @@ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
|
|
|
38
38
|
/**
|
|
39
39
|
* Reciple builder for slash command
|
|
40
40
|
*/
|
|
41
|
-
export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties {
|
|
41
|
+
export declare class SlashCommandBuilder<T extends unknown = any> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
|
|
42
42
|
readonly type = CommandBuilderType.SlashCommand;
|
|
43
43
|
cooldown: number;
|
|
44
44
|
requiredBotPermissions: PermissionResolvable[];
|
|
45
45
|
requiredMemberPermissions: PermissionResolvable[];
|
|
46
46
|
halt?: SlashCommandHaltFunction;
|
|
47
47
|
execute: SlashCommandExecuteFunction;
|
|
48
|
-
|
|
48
|
+
metadata?: T;
|
|
49
|
+
constructor(data?: Partial<Omit<SlashCommandData<T>, "type">>);
|
|
49
50
|
setCooldown(cooldown: number): this;
|
|
50
51
|
setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
51
52
|
setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
|
|
52
53
|
setHalt(halt?: SlashCommandHaltFunction | null): this;
|
|
53
54
|
setExecute(execute: SlashCommandExecuteFunction): this;
|
|
55
|
+
setMetadata(metadata?: T): this;
|
|
54
56
|
/**
|
|
55
57
|
* Add option builder to command builder
|
|
56
58
|
*/
|
|
@@ -59,11 +61,11 @@ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder im
|
|
|
59
61
|
* Resolve option data
|
|
60
62
|
*/
|
|
61
63
|
static resolveOption<T extends AnySlashCommandOptionBuilder>(option: AnySlashCommandOptionData): T;
|
|
62
|
-
static resolveSlashCommand(commandData: SlashCommandData | AnySlashCommandBuilder): AnySlashCommandBuilder;
|
|
64
|
+
static resolveSlashCommand<T extends unknown = any>(commandData: SlashCommandData<T> | AnySlashCommandBuilder<T>): AnySlashCommandBuilder;
|
|
63
65
|
/**
|
|
64
66
|
* Is a slash command builder
|
|
65
67
|
*/
|
|
66
|
-
static isSlashCommandBuilder(builder: unknown): builder is AnySlashCommandBuilder
|
|
68
|
+
static isSlashCommandBuilder<T extends unknown = any>(builder: unknown): builder is AnySlashCommandBuilder<T>;
|
|
67
69
|
/**
|
|
68
70
|
* Is a slash command execute data
|
|
69
71
|
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
2
1
|
import { Guild, GuildTextBasedChannel, PermissionResolvable } from 'discord.js';
|
|
2
|
+
import { UserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
3
3
|
/**
|
|
4
4
|
* Check if the user has permissions to execute the given command name
|
|
5
5
|
* @param options options
|
|
File without changes
|
|
@@ -5,15 +5,15 @@ import { MessageCommandOptionBuilder } from '../classes/builders/MessageCommandO
|
|
|
5
5
|
/**
|
|
6
6
|
* Any command builders
|
|
7
7
|
*/
|
|
8
|
-
export declare type AnyCommandBuilder = AnySlashCommandBuilder | MessageCommandBuilder
|
|
8
|
+
export declare type AnyCommandBuilder<T extends unknown = any> = AnySlashCommandBuilder<T> | MessageCommandBuilder<T>;
|
|
9
9
|
/**
|
|
10
10
|
* Any command data
|
|
11
11
|
*/
|
|
12
|
-
export declare type AnyCommandData = SlashCommandData | MessageCommandData
|
|
12
|
+
export declare type AnyCommandData<T extends unknown = any> = SlashCommandData<T> | MessageCommandData<T>;
|
|
13
13
|
/**
|
|
14
14
|
* Any slash command builders
|
|
15
15
|
*/
|
|
16
|
-
export declare type AnySlashCommandBuilder = SlashCommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder
|
|
16
|
+
export declare type AnySlashCommandBuilder<T extends unknown = any> = SlashCommandBuilder<T> | SlashCommandOptionsOnlyBuilder<T> | SlashCommandSubcommandsOnlyBuilder<T>;
|
|
17
17
|
/**
|
|
18
18
|
* Any command halt functions
|
|
19
19
|
*/
|
|
@@ -45,11 +45,11 @@ export declare type AnySlashCommandOptionBuilder = AnySlashCommandOptionsOnlyOpt
|
|
|
45
45
|
/**
|
|
46
46
|
* Slash command options without sub commands
|
|
47
47
|
*/
|
|
48
|
-
export declare type AnySlashCommandOptionsOnlyOptionData =
|
|
48
|
+
export declare type AnySlashCommandOptionsOnlyOptionData = SlashCommandAttachmentOptionData | SlashCommandBooleanOptionData | SlashCommandChannelOptionData | SlashCommandIntegerOptionData | SlashCommandMentionableOptionData | SlashCommandNumberOptionData | SlashCommandRoleOptionData | SlashCommandStringOptionData | SlashCommandUserOptionData;
|
|
49
49
|
/**
|
|
50
50
|
* Slash command option builder without sub commands
|
|
51
51
|
*/
|
|
52
|
-
export declare type AnySlashCommandOptionsOnlyOptionBuilder =
|
|
52
|
+
export declare type AnySlashCommandOptionsOnlyOptionBuilder = SlashCommandAttachmentOption | SlashCommandBooleanOption | SlashCommandChannelOption | SlashCommandIntegerOption | SlashCommandMentionableOption | SlashCommandNumberOption | SlashCommandRoleOption | SlashCommandStringOption | SlashCommandUserOption;
|
|
53
53
|
/**
|
|
54
54
|
* Types of command builders
|
|
55
55
|
*/
|
|
@@ -60,13 +60,14 @@ export declare enum CommandBuilderType {
|
|
|
60
60
|
/**
|
|
61
61
|
* Shared command builder methods and properties
|
|
62
62
|
*/
|
|
63
|
-
export interface SharedCommandBuilderProperties {
|
|
63
|
+
export interface SharedCommandBuilderProperties<T extends unknown> {
|
|
64
64
|
readonly type: CommandBuilderType;
|
|
65
65
|
cooldown: number;
|
|
66
66
|
requiredBotPermissions: PermissionResolvable[];
|
|
67
67
|
requiredMemberPermissions: PermissionResolvable[];
|
|
68
68
|
halt?: AnyCommandHaltFunction;
|
|
69
69
|
execute: AnyCommandExecuteFunction;
|
|
70
|
+
metadata?: T;
|
|
70
71
|
/**
|
|
71
72
|
* Sets the execute cooldown for this command.
|
|
72
73
|
* - `0` means no cooldown
|
|
@@ -93,6 +94,11 @@ export interface SharedCommandBuilderProperties {
|
|
|
93
94
|
* @param execute Function to execute when the command is called
|
|
94
95
|
*/
|
|
95
96
|
setExecute(execute: this["execute"]): this;
|
|
97
|
+
/**
|
|
98
|
+
* Set a command metadata
|
|
99
|
+
* @param metadata Command metadata
|
|
100
|
+
*/
|
|
101
|
+
setMetadata(metadata?: T): this;
|
|
96
102
|
}
|
|
97
103
|
/**
|
|
98
104
|
* Shared command name and description properties
|
|
@@ -104,7 +110,7 @@ export interface SharedCommandDataProperties {
|
|
|
104
110
|
/**
|
|
105
111
|
* Slash command object data interface
|
|
106
112
|
*/
|
|
107
|
-
export interface SlashCommandData extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties
|
|
113
|
+
export interface SlashCommandData<T extends unknown = any> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
|
|
108
114
|
type: CommandBuilderType.SlashCommand;
|
|
109
115
|
nameLocalizations?: LocalizationMap;
|
|
110
116
|
descriptionLocalizations?: LocalizationMap;
|
|
@@ -172,7 +178,7 @@ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProper
|
|
|
172
178
|
/**
|
|
173
179
|
* Message command object data interface
|
|
174
180
|
*/
|
|
175
|
-
export interface MessageCommandData extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties
|
|
181
|
+
export interface MessageCommandData<T extends unknown = any> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
|
|
176
182
|
type: CommandBuilderType.MessageCommand;
|
|
177
183
|
aliases?: string[];
|
|
178
184
|
validateOptions?: boolean;
|
|
@@ -186,8 +192,6 @@ export interface MessageCommandData extends SharedCommandDataProperties, Partial
|
|
|
186
192
|
* Message command option object data interface
|
|
187
193
|
*/
|
|
188
194
|
export interface MessageCommandOptionData extends SharedCommandDataProperties {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
required: boolean;
|
|
192
|
-
validator: (value: string) => Awaitable<boolean>;
|
|
195
|
+
required?: boolean;
|
|
196
|
+
validator?: (value: string) => Awaitable<boolean>;
|
|
193
197
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# [VIEW DOCS](https://reciple.js.org/#/docs)
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"bin": "
|
|
3
|
+
"version": "5.5.0",
|
|
4
|
+
"bin": "dist/cjs/bin.js",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
|
-
"main": "
|
|
7
|
-
"typings": "
|
|
6
|
+
"main": "dist/cjs/index.js",
|
|
7
|
+
"typings": "dist/types/index.d.ts",
|
|
8
8
|
"author": "FalloutStudios",
|
|
9
9
|
"description": "Handler for Discord.js",
|
|
10
10
|
"homepage": "https://reciple.js.org",
|
|
@@ -20,19 +20,14 @@
|
|
|
20
20
|
"url": "https://github.com/FalloutStudios/reciple/issues"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"clean": "yarn exec rimraf
|
|
23
|
+
"clean": "yarn exec rimraf dist",
|
|
24
24
|
"build": "yarn clean && yarn exec tsc",
|
|
25
|
-
"build:publish": "yarn build && yarn
|
|
25
|
+
"build:publish": "yarn build && yarn docs && yarn npm publish",
|
|
26
26
|
"build:publish-prerelease": "yarn build && yarn npm publish --tag pre",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"test:start": "cd test && yarn exec reciple -D",
|
|
31
|
-
"publish:docs": "yarn build:docs && yarn update:docs"
|
|
27
|
+
"test": "yarn build && yarn workspace test start",
|
|
28
|
+
"docs": "yarn exec docgen --typescript true -c ./docs/index.json -o ./docs/docs.json -i src/index.ts",
|
|
29
|
+
"watch": "yarn exec tsc --watch --noEmit"
|
|
32
30
|
},
|
|
33
|
-
"workspaces": [
|
|
34
|
-
"./docs/"
|
|
35
|
-
],
|
|
36
31
|
"repository": {
|
|
37
32
|
"type": "git",
|
|
38
33
|
"url": "git+https://github.com/FalloutStudios/reciple.git"
|
|
@@ -42,7 +37,7 @@
|
|
|
42
37
|
"node": ">=16.9.0"
|
|
43
38
|
},
|
|
44
39
|
"files": [
|
|
45
|
-
"
|
|
40
|
+
"dist",
|
|
46
41
|
"resource",
|
|
47
42
|
"package.json",
|
|
48
43
|
"LICENSE",
|
|
@@ -58,18 +53,21 @@
|
|
|
58
53
|
"yaml": "^2.1.1"
|
|
59
54
|
},
|
|
60
55
|
"devDependencies": {
|
|
61
|
-
"@
|
|
56
|
+
"@discordjs/docgen": "^0.12.1",
|
|
57
|
+
"@types/node": "^18.7.18",
|
|
62
58
|
"@types/semver": "^7.3.12",
|
|
63
59
|
"discord.js": "^14.3.0",
|
|
64
60
|
"rimraf": "^3.0.2",
|
|
65
|
-
"typedoc": "^0.23.14",
|
|
66
61
|
"typedoc-plugin-discord-types": "^1.0.2",
|
|
67
62
|
"typedoc-plugin-djs-links": "^1.2.0",
|
|
68
63
|
"typedoc-plugin-mdn-links": "^2.0.0",
|
|
69
|
-
"typescript": "^4.8.
|
|
64
|
+
"typescript": "^4.8.3"
|
|
70
65
|
},
|
|
71
66
|
"peerDependencies": {
|
|
72
|
-
"discord.js": "^14.
|
|
67
|
+
"discord.js": "^14.1.0"
|
|
73
68
|
},
|
|
69
|
+
"workspaces": [
|
|
70
|
+
"test"
|
|
71
|
+
],
|
|
74
72
|
"packageManager": "yarn@3.2.2"
|
|
75
73
|
}
|
package/resource/reciple.yml
CHANGED
|
@@ -39,6 +39,8 @@ commands:
|
|
|
39
39
|
registerCommands: true
|
|
40
40
|
# set required permissions for interaction commands
|
|
41
41
|
setRequiredPermissions: true
|
|
42
|
+
# accept replied or deffered command interaction
|
|
43
|
+
acceptRepliedInteractions: false
|
|
42
44
|
# register commands to specific guild(s) empty to make it global
|
|
43
45
|
guilds: []
|
|
44
46
|
# overwrite command permissions
|