reciple 5.1.1 → 5.1.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/README.md CHANGED
@@ -17,7 +17,22 @@
17
17
  A simple Dicord.js handler that just works.
18
18
  </h3>
19
19
 
20
- ****
20
+ ***
21
+
22
+ <p align="center">
23
+ <a href="https://discord.gg/2CattJYNpw" title="">
24
+ <img src="https://i.imgur.com/GffJByO.png" alt="Join Discord">
25
+ </a>
26
+ </p>
27
+
28
+ # Features
29
+
30
+ * [CLI based handler](#command-line)
31
+ * [Message command builder](#messagecommandbuilder-example)
32
+ * [Built-in message command validation](#built-in-message-command-validation)
33
+ * Automatically register application commands
34
+ * [Built-in command cooldowns](#command-cooldowns)
35
+ * [Highly configurable](#config)
21
36
 
22
37
  ## Installation
23
38
 
@@ -74,13 +89,100 @@ To start the bot, run the following command:
74
89
  npx reciple
75
90
  ```
76
91
 
77
- > ## Fun Fact
78
- > The name reciple is from a minecraft bug. The bug was a misspelling of the word `recipe`. [View Mojang Bug Report](https://bugs.mojang.com/browse/MC-225837)
92
+ ## Command line
93
+
94
+ **Usage:** `reciple [options] [current-working-directory]`
95
+
96
+ **Arguments:**
97
+ * `current-working-directory` Change the current working directory
98
+
99
+ **Options:**
100
+ * `-v, --version` output the version number
101
+ * `-t, --token <token>` Replace used bot token
102
+ * `-c, --config <config>` Change path to config file
103
+ * `-D, --debugmode` Enable debug mode
104
+ * `-y, --yes` Automatically agree to Reciple confirmation prompts
105
+ * `-v, --version` Display version
106
+ * `-h, --help` display help for command
107
+
108
+ ## MessageCommandBuilder Example
79
109
 
110
+ * Read docs for [`MessageCommandBuilder`](https://reciple.js.org/classes/MessageCommandBuilder.html)
80
111
 
81
- # Join Discord
82
- [![Discord Invite](https://i.imgur.com/GffJByO.png)](https://discord.gg/2CattJYNpw)
112
+ ```js
113
+ new MessageCommandBuilder()
114
+ .setName("command")
115
+ .setDescription("Your lil tiny description")
116
+ .addAliases('cmd', 'cmd1')
117
+ .setExecute(command => command.message.reply("Hello!"))
118
+ ```
119
+
120
+ ## Built-in message command validation
121
+
122
+ * Read docs for [`MessageCommandBuilder#setValidateOptions()`](https://reciple.js.org/classes/MessageCommandBuilder.html#setValidateOptions)
123
+ * Read docs for [`MessageCommandOptionBuilder`](https://reciple.js.org/classes/MessageCommandOptionBuilder.html)
124
+ * Read docs for [`MessageCommandOptionManager`](https://reciple.js.org/classes/MessageCommandOptionManager.html)
125
+ ```js
126
+ new MessageCommandBuilder()
127
+ .setName("command")
128
+ .setDescription("Your lil tiny description")
129
+ .addAliases('cmd', 'cmd1')
130
+ .setValidateOptions(true) // Validate options
131
+ .addOption(option => option
132
+ .setName("quantity")
133
+ .setDescription("Must be a number")
134
+ .setRequired(true) // A required option
135
+ .setValidator(val => !isNaN(Number(val))) // Validate value
136
+ )
137
+ .setExecute(async command => {
138
+ const quantity = Number(command.options.getValue('quantity', true));
139
+
140
+ await command.message.reply("Quantity: " + quantity);
141
+ })
142
+ ```
143
+
144
+ ## Command Cooldowns
145
+
146
+ * Read docs for [`SlashCommandBuilder#setCooldown()`](https://reciple.js.org/classes/SlashCommandBuilder.html#setCooldown)
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)
150
+
151
+ ```js
152
+ // Slash command
153
+ new SlashCommandBuilder()
154
+ .setName("command")
155
+ .setDescription("Your lil tiny description")
156
+ .setCooldown(1000 * 60) // Cooldown in milliseconds
157
+ .setExecute(command => command.interaction.reply('hi'))
158
+ .setHalt(async halt => {
159
+ // Handle command on cooldown
160
+ if (halt.reason == CommandHaltReason.Cooldown) {
161
+ await halt.executeData.interaction.reply((halt.expireTime - Date.now()) / 1000 + " seconds cooldown");
162
+ return true;
163
+ }
164
+ })
165
+
166
+ // Message command
167
+ new MessageCommandBuilder()
168
+ .setName("command")
169
+ .setDescription("Your lil tiny description")
170
+ .setCooldown(1000 * 60) // Cooldown in milliseconds
171
+ .setExecute(command => command.message.reply('hi'))
172
+ .setHalt(async halt => {
173
+ // Handle command on cooldown
174
+ if (halt.reason == CommandHaltReason.Cooldown) {
175
+ await halt.executeData.message.reply((halt.expireTime - Date.now()) / 1000 + " seconds cooldown");
176
+ return true;
177
+ }
178
+ })
179
+ ```
180
+
181
+ ***
182
+
183
+ > ## Fun Fact
184
+ > The name reciple is from a minecraft bug. The bug was a misspelling of the word `recipe`. [View Mojang Bug Report](https://bugs.mojang.com/browse/MC-225837)
83
185
 
84
- ****
186
+ ***
85
187
 
86
188
  [#letTheEarthBreathe](https://rebellion.global/)
@@ -1,9 +1,9 @@
1
1
  import { MessageCommandBuilder, MessageCommandExecuteData } from './builders/MessageCommandBuilder';
2
2
  import { SlashCommandBuilder, SlashCommandExecuteData } from './builders/SlashCommandBuilder';
3
3
  import { ApplicationCommandBuilder } from '../registerApplicationCommands';
4
+ import { AnyCommandBuilder, AnySlashCommandBuilder, CommandBuilderType } from '../types/builders';
4
5
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
5
6
  import { CommandCooldownManager } from './CommandCooldownManager';
6
- import { AnyCommandBuilder, CommandBuilderType } from '../types/builders';
7
7
  import { RecipleClientAddModuleOptions } from '../types/paramOptions';
8
8
  import { Logger as ILogger } from 'fallout-utility';
9
9
  import { Config } from './RecipleConfig';
@@ -20,7 +20,7 @@ export interface RecipleClientOptions extends ClientOptions {
20
20
  */
21
21
  export interface RecipleClientCommands {
22
22
  slashCommands: {
23
- [commandName: string]: SlashCommandBuilder;
23
+ [commandName: string]: AnySlashCommandBuilder;
24
24
  };
25
25
  messageCommands: {
26
26
  [commandName: string]: MessageCommandBuilder;
@@ -16,11 +16,11 @@ exports.RecipleClient = void 0;
16
16
  const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
17
17
  const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
18
18
  const registerApplicationCommands_1 = require("../registerApplicationCommands");
19
+ const builders_1 = require("../types/builders");
19
20
  const commands_1 = require("../types/commands");
20
21
  const permissions_1 = require("../permissions");
21
22
  const CommandCooldownManager_1 = require("./CommandCooldownManager");
22
23
  const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
23
- const builders_1 = require("../types/builders");
24
24
  const fallout_utility_1 = require("fallout-utility");
25
25
  const RecipleConfig_1 = require("./RecipleConfig");
26
26
  const modules_1 = require("../modules");
@@ -1,5 +1,5 @@
1
1
  import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties } from '../../types/builders';
2
- import { AnyCommandExecuteData, BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
2
+ import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
3
3
  import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
4
4
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
5
5
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
@@ -90,15 +90,15 @@ export declare class MessageCommandBuilder implements SharedCommandBuilderProper
90
90
  setCooldown(cooldown: number): this;
91
91
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
92
92
  setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
93
- setHalt(halt?: this["halt"]): this;
94
- setExecute(execute: this["execute"]): this;
93
+ setHalt(halt?: MessageCommandHaltFunction | null): this;
94
+ setExecute(execute: MessageCommandExecuteFunction): this;
95
95
  /**
96
96
  * Is a message command builder
97
97
  */
98
- static isMessageCommandBuilder(builder: any): builder is MessageCommandBuilder;
98
+ static isMessageCommandBuilder(builder: unknown): builder is MessageCommandBuilder;
99
99
  /**
100
100
  * Is a message command execute data
101
101
  */
102
- static isMessageCommandExecuteData(executeData: AnyCommandExecuteData): executeData is MessageCommandExecuteData;
102
+ static isMessageCommandExecuteData(executeData: unknown): executeData is MessageCommandExecuteData;
103
103
  }
104
104
  export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): Promise<MessageCommandOptionManager>;
@@ -125,7 +125,7 @@ class MessageCommandBuilder {
125
125
  return this;
126
126
  }
127
127
  setHalt(halt) {
128
- this.halt = halt ? halt : undefined;
128
+ this.halt = halt !== null && halt !== void 0 ? halt : undefined;
129
129
  return this;
130
130
  }
131
131
  setExecute(execute) {
@@ -1,12 +1,12 @@
1
- import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties } from '../../types/builders';
2
- import { AnyCommandExecuteData, BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
3
- import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
1
+ import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, AnySlashCommandBuilder } from '../../types/builders';
2
+ import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
3
+ import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, SlashCommandRoleOption, SlashCommandAttachmentOption, SlashCommandMentionableOption, SlashCommandStringOption, SlashCommandIntegerOption, SlashCommandNumberOption } from 'discord.js';
4
4
  /**
5
5
  * Execute data for slash command
6
6
  */
7
7
  export interface SlashCommandExecuteData extends BaseCommandExecuteData {
8
8
  interaction: ChatInputCommandInteraction;
9
- builder: SlashCommandBuilder;
9
+ builder: AnySlashCommandBuilder;
10
10
  }
11
11
  /**
12
12
  * Slash command halt data
@@ -20,16 +20,25 @@ 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 interface SlashCommandSubcommandsOnlyBuilder extends DiscordJsSlashCommandSubcommandsOnlyBuilder, Pick<SlashCommandBuilder, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute"> {
24
- }
23
+ export declare type SlashCommandSubcommandsOnlyBuilder = Omit<SlashCommandBuilder, "addBooleanOption" | "addUserOption" | "addChannelOption" | "addRoleOption" | "addAttachmentOption" | "addMentionableOption" | "addStringOption" | "addIntegerOption" | "addNumberOption">;
24
+ export declare type SlashCommandOptionsOnlyBuilder = Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">;
25
25
  export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
26
26
  addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
27
27
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
28
+ addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
29
+ addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
30
+ addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
31
+ addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
32
+ addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
33
+ addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
34
+ addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
35
+ addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
36
+ addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
28
37
  }
29
38
  /**
30
39
  * Reciple builder for slash command
31
40
  */
32
- export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties, SlashCommandBuilder {
41
+ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties {
33
42
  readonly type = CommandBuilderType.SlashCommand;
34
43
  cooldown: number;
35
44
  requiredBotPermissions: PermissionResolvable[];
@@ -40,14 +49,14 @@ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder im
40
49
  setCooldown(cooldown: number): this;
41
50
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
42
51
  setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
43
- setHalt(halt?: this["halt"]): this;
44
- setExecute(execute: this["execute"]): this;
52
+ setHalt(halt?: SlashCommandHaltFunction | null): this;
53
+ setExecute(execute: SlashCommandExecuteFunction): this;
45
54
  /**
46
55
  * Is a slash command builder
47
56
  */
48
- static isSlashCommandBuilder(builder: any): builder is SlashCommandBuilder;
57
+ static isSlashCommandBuilder(builder: unknown): builder is SlashCommandBuilder;
49
58
  /**
50
59
  * Is a slash command execute data
51
60
  */
52
- static isSlashCommandExecuteData(executeData: AnyCommandExecuteData): executeData is SlashCommandExecuteData;
61
+ static isSlashCommandExecuteData(executeData: unknown): executeData is SlashCommandExecuteData;
53
62
  }
@@ -29,7 +29,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
29
29
  return this;
30
30
  }
31
31
  setHalt(halt) {
32
- this.halt = halt ? halt : undefined;
32
+ this.halt = halt !== null && halt !== void 0 ? halt : undefined;
33
33
  return this;
34
34
  }
35
35
  setExecute(execute) {
@@ -10,8 +10,8 @@ export declare type LoadedModules = {
10
10
  export interface RecipleScript {
11
11
  versions: string | string[];
12
12
  commands?: AnyCommandBuilder[];
13
- onLoad?(reciple: RecipleClient): void | Promise<void>;
14
- onStart(reciple: RecipleClient): boolean | Promise<boolean>;
13
+ onLoad?(client: RecipleClient): void | Promise<void>;
14
+ onStart(client: RecipleClient): boolean | Promise<boolean>;
15
15
  }
16
16
  /**
17
17
  * Reciple module object
@@ -1,7 +1,7 @@
1
1
  import { ContextMenuCommandBuilder, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
2
- import { SlashCommandBuilder } from './classes/builders/SlashCommandBuilder';
3
2
  import { RegisterApplicationCommandsOptions } from './types/paramOptions';
4
- export declare type ApplicationCommandBuilder = SlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
3
+ import { AnySlashCommandBuilder } from './types/builders';
4
+ export declare type ApplicationCommandBuilder = AnySlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
5
5
  /**
6
6
  * Register application commands
7
7
  * @param options Register application commands options
@@ -1,10 +1,14 @@
1
1
  import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandExecuteFunction, MessageCommandHaltData, MessageCommandHaltFunction } from '../classes/builders/MessageCommandBuilder';
2
- import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction } from '../classes/builders/SlashCommandBuilder';
2
+ import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder } from '../classes/builders/SlashCommandBuilder';
3
3
  import { Awaitable, PermissionResolvable, RestOrArray } from 'discord.js';
4
4
  /**
5
5
  * Any command builders
6
6
  */
7
- export declare type AnyCommandBuilder = SlashCommandBuilder | MessageCommandBuilder;
7
+ export declare type AnyCommandBuilder = AnySlashCommandBuilder | MessageCommandBuilder;
8
+ /**
9
+ * Any slash command builders
10
+ */
11
+ export declare type AnySlashCommandBuilder = SlashCommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder;
8
12
  /**
9
13
  * Any command halt functions
10
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "bin": "bin/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "bin/index.js",
@@ -57,8 +57,8 @@
57
57
  "yaml": "^2.1.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "^18.7.1",
61
- "@types/semver": "^7.3.11",
60
+ "@types/node": "^18.7.6",
61
+ "@types/semver": "^7.3.12",
62
62
  "discord.js": "^14.2.0",
63
63
  "rimraf": "^3.0.2",
64
64
  "typedoc": "^0.23.10",