create-reciple 7.10.0-dev.0 → 7.10.0-dev.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.
Files changed (2) hide show
  1. package/assets/README.md +77 -25
  2. package/package.json +3 -3
package/assets/README.md CHANGED
@@ -1,10 +1,11 @@
1
- # Introduction
1
+ # Reciple
2
2
 
3
- Reciple is a discord.js command handler framework.
3
+ Reciple is a discord.js command handler framework that just works.
4
4
 
5
5
  ## Reciple Modules
6
6
 
7
- Reciple scans the directory assigned in `reciple.yml` under `modules.modulesFolders` property. `modules.modulesFolders` can be the path of the folder of modules or glob pattern
7
+ - Reciple scans the directory assigned in `reciple.yml` under `modules.modulesFolders` property.
8
+ - `modules.modulesFolders` can be the path of the folder of modules or glob pattern
8
9
 
9
10
  ### Folder Structure
10
11
 
@@ -58,13 +59,7 @@ Module files can be ES Modules or CommonJs.
58
59
 
59
60
  #### Module file structure
60
61
 
61
- | Property | type | Required | Description |
62
- |---|---|:---:|---|
63
- | `versions` | `string\|string[]` | `true` | The versions of the Reciple client that the module script is compatible with. The versions can be a string or an array of strings. |
64
- | `commands` | `(AnyCommandBuilder\|AnyCommandData)[]]` | `false` | The commands that are defined by the module script. |
65
- | `onStart` | `(client: RecipleClient, module: RecipleModule) => Awaitable<boolean>` | `true` | The function that is called when the module script is started. The function must return a boolean value or a promise that resolves to a boolean value. The boolean value indicates whether the module script was started successfully. |
66
- | `onLoad` | `(client: RecipleClient, module: RecipleModule) => Awaitable<void>` | `false` | The function that is called when the module script is loaded. |
67
- | `onUnload` | `(unloadData: RecipleModuleUnloadData) => Awaitable<void>` | `false` | The function that is called when the module script is unloaded. |
62
+ - [RecipleModuleScript](https://reciple.js.org/docs/client/main/typedefs/RecipleModuleScript)
68
63
 
69
64
  #### ESM module example
70
65
 
@@ -132,7 +127,7 @@ module.exports = new MyModule();
132
127
 
133
128
  ## Reciple Commands
134
129
 
135
- instead of importing builders from you'll need to import command builders from `reciple` or `@reciple/client`.
130
+ instead of importing builders from `discord.js`, import command builders from `reciple` or `@reciple/client`.
136
131
 
137
132
  ```diff
138
133
  - const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('discord.js');
@@ -162,22 +157,12 @@ export default {
162
157
 
163
158
  ### Interaction command execute params
164
159
 
165
- | Param | Type | Required | Description |
166
- |---|---|:---:|---|
167
- | `interaction` | `ChatInputCommandInteraction\|AnyContextMenuCommandInteraction` | `true` | The command interaction that triggers the command |
168
- | `client` | `RecipleCommand` | `true` | The current bot client |
169
- | `builder` | `AnySlashCommandBuilder\|ContextMenuCommandBuilder` | `true` | The builder of the executed command |
170
- | `commandType` | `CommandType` | `true` | The type of executed command |
160
+ - [ContextMenuCommandExecuteData](https://reciple.js.org/docs/client/main/typedefs/ContextMenuCommandExecuteData)
161
+ - [SlashCommandExecuteData](https://reciple.js.org/docs/client/main/typedefs/SlashCommandExecuteData)
171
162
 
172
163
  ### Message command execute params
173
164
 
174
- | Param | Type | Required | Description |
175
- |---|---|:---:|---|
176
- | `message` | `Message` | `true` | The message that triggers the command |
177
- | `client` | `RecipleCommand` | `true` | The current bot client |
178
- | `builder` | `AnySlashCommandBuilder\|ContextMenuCommandBuilder` | `true` | The builder of the executed command |
179
- | `commandType` | `CommandType` | `true` | The type of executed command |
180
- | `options` | `MessageCommandOptionManager` | `true` | The parsed options passed to this command |
165
+ - [MessageCommandExecuteData](https://reciple.js.org/docs/client/main/typedefs/MessageCommandExecuteData)
181
166
 
182
167
  ### Handling command execute errors
183
168
 
@@ -193,7 +178,7 @@ new SlashCommandBuilder()
193
178
  .setHalt(async haltData => {
194
179
  switch (haltData.reason) {
195
180
  case CommandHaltReason.Cooldown:
196
- await haltData.executeData.interaction.followUp('You\'ve been cooled-down');
181
+ await haltData.executeData.interaction.followUp(`You've been cooled-down`);
197
182
  return true;
198
183
  case CommandHaltReason.Error:
199
184
  await haltData.executeData.interaction.followUp('An error occured');
@@ -203,3 +188,70 @@ new SlashCommandBuilder()
203
188
  // The rest is unhandled
204
189
  })
205
190
  ```
191
+
192
+ ### Using command preconditions
193
+
194
+ Command preconditions are executed after the command is received and before executing the command's execute function.
195
+
196
+ #### Module command preconditions
197
+
198
+ You can define a precondition for all commands of a module.
199
+
200
+ ##### Valid module precondition methods
201
+
202
+ - [Context meny command preconditions](https://reciple.js.org/docs/client/main/typedefs/RecipleModuleScript#contextMenuCommandPrecondition)
203
+ - [Message command preconditions](https://reciple.js.org/docs/client/main/typedefs/RecipleModuleScript#messageCommandPrecondition)
204
+ - [Slash command preconditions](https://reciple.js.org/docs/client/main/typedefs/RecipleModuleScript#slashCommandPrecondition)
205
+
206
+ ```js
207
+ // Example module with slash commands precondition
208
+ export default {
209
+ versions: '^7',
210
+ commands: [
211
+ new SlashCommandBuilder()
212
+ .setName('ping')
213
+ .setDescription('Just a ping command')
214
+ .setExecute(async ({ interaction }) => {
215
+ await interaction.reply('Pong');
216
+ })
217
+ ],
218
+ onStart: async client => true,
219
+
220
+ // creates a slash command precondition
221
+ slashCommandPrecondition: async (({ interaction })) => {
222
+ return !interaction.inCachedGuild() || interaction.guild.ownerId !== interaction.user.id; // Command can only be executed by the guild owner
223
+ }
224
+ };
225
+ ```
226
+
227
+ #### Global command preconditions
228
+
229
+ Global preconditions are added to all commands along with the existing module preconditions.
230
+
231
+ ##### Set & Get global preconditions
232
+ - [CommandManager#setGlobalPrecondition](https://reciple.js.org/docs/client/main/classes/CommandManager#setGlobalPrecondition)
233
+ - [CommandManager#getGlobalPrecondition](https://reciple.js.org/docs/client/main/classes/CommandManager#getGlobalPrecondition)
234
+
235
+ ```js
236
+ // Example module with global slash commands precondition
237
+ export default {
238
+ versions: '^7',
239
+ commands: [
240
+ new SlashCommandBuilder()
241
+ .setName('ping')
242
+ .setDescription('Just a ping command')
243
+ .setExecute(async ({ interaction }) => {
244
+ await interaction.reply('Pong');
245
+ })
246
+ ],
247
+ onStart: async client => true,
248
+ onLoad: async client => {
249
+ client.commands.setGlobalPrecondition(
250
+ CommandType.SlashCommand,
251
+ async ({ interaction }) => {
252
+ return interaction.inCachedGuild(); // All slash commands can only be executed if in cached guild
253
+ }
254
+ );
255
+ }
256
+ };
257
+ ```
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "create-reciple",
3
3
  "description": "A Reciple Discord bot project builder",
4
4
  "license": "GPL-3.0",
5
- "version": "7.10.0-dev.0",
5
+ "version": "7.10.0-dev.2",
6
6
  "type": "module",
7
7
  "types": "./bin/bin.d.ts",
8
8
  "bin": "./bin/bin.js",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "discord.js": "^14.11.0",
32
32
  "nodemon": "^2.0.22",
33
- "reciple": "^7.8.0-dev.0"
33
+ "reciple": "^7.8.0-dev.2"
34
34
  },
35
- "gitHead": "3e6e67522d3746969be52d3eda54b93f36f271cd"
35
+ "gitHead": "ec5627f206981af4f0e4897a4d55363f2caa1db6"
36
36
  }