create-reciple 7.7.4 → 7.8.0-dev.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.
Files changed (2) hide show
  1. package/assets/README.md +205 -0
  2. package/package.json +3 -4
@@ -0,0 +1,205 @@
1
+ # Introduction
2
+
3
+ Reciple is a discord.js command handler framework.
4
+
5
+ ## Reciple Modules
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
8
+
9
+ ### Folder Structure
10
+
11
+ ##### Example Structure
12
+ ```yml
13
+ # Modules config
14
+
15
+ modules:
16
+ modulesFolders:
17
+ - './modules' # Scans the modules folder for module files
18
+ ```
19
+
20
+ ```
21
+ # Dir structure
22
+
23
+ modules/
24
+ ├─ Module1.js
25
+ ├─ Module2.js
26
+ ```
27
+
28
+ ##### Example Structure with Glob patterns
29
+ ```yml
30
+ # Modules config
31
+
32
+ modules:
33
+ modulesFolders:
34
+ - './modules' # Scans the modules folder for module files
35
+ - './modules/*' # Scans the folders of modules folder for module files
36
+ ```
37
+
38
+ ```
39
+ # Dir structure
40
+
41
+ modules/
42
+ ├─ moreModules/
43
+ │ ├─ Module1.js
44
+ │ ├─ Module2.js
45
+ ├─ Module3.js
46
+ ├─ Module4.js
47
+ ```
48
+
49
+ ### Module Structure
50
+
51
+ Module files can be ES Modules or CommonJs.
52
+
53
+ ##### Supported module file types
54
+
55
+ - `.js` *This can be an ESM or CJS*
56
+ - `.mjs`
57
+ - `.cjs`
58
+
59
+ #### Module file structure
60
+
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. |
68
+
69
+ #### ESM module example
70
+
71
+ ```js
72
+ // Usage without classes
73
+
74
+ export default {
75
+ versions: '^7',
76
+ onStart: async client => {
77
+ return true;
78
+ },
79
+ onLoad: async client => {},
80
+ onUnload: async ({ client }) => {}
81
+ };
82
+ ```
83
+ ```js
84
+ // Usage with classes
85
+
86
+ export class MyModule {
87
+ versions = '^7';
88
+ commands = [];
89
+
90
+ async onStart(client) {
91
+ return true;
92
+ }
93
+
94
+ async onLoad(client) {}
95
+ async onUnload(unloadData) {}
96
+ }
97
+
98
+ export default new MyModule();
99
+ ```
100
+
101
+ #### CommonJS module example
102
+
103
+ ```js
104
+ // Usage without classes
105
+
106
+ module.exports = {
107
+ versions: '^7',
108
+ onStart: async client => {
109
+ return true;
110
+ },
111
+ onLoad: async client => {},
112
+ onUnload: async ({ client }) => {}
113
+ };
114
+ ```
115
+ ```js
116
+ // Usage with classes
117
+
118
+ class MyModule {
119
+ versions = '^7';
120
+ commands = [];
121
+
122
+ async onStart(client) {
123
+ return true;
124
+ }
125
+
126
+ async onLoad(client) {}
127
+ async onUnload(unloadData) {}
128
+ }
129
+
130
+ module.exports = new MyModule();
131
+ ```
132
+
133
+ ## Reciple Commands
134
+
135
+ instead of importing builders from you'll need to import command builders from `reciple` or `@reciple/client`.
136
+
137
+ ```diff
138
+ - const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('discord.js');
139
+ - import { SlashCommandBuilder, ContextMenuCommandBuilder } from 'discord.js';
140
+ + const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('reciple');
141
+ + import { SlashCommandBuilder, ContextMenuCommandBuilder } from 'reciple';
142
+ ```
143
+
144
+ You can add your commands in the commands property of your module script.
145
+
146
+ ```js
147
+ export default {
148
+ versions: '^7',
149
+ commands: [
150
+ new SlashCommandBuilder()
151
+ .setName('ping')
152
+ .setDescription('Just a ping command')
153
+ .setExecute(async ({ interaction }) => {
154
+ await interaction.reply('Pong');
155
+ })
156
+ ],
157
+ onStart: async client => {
158
+ return true;
159
+ }
160
+ };
161
+ ```
162
+
163
+ ### Interaction command execute params
164
+
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 |
171
+
172
+ ### Message command execute params
173
+
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 |
181
+
182
+ ### Handling command execute errors
183
+
184
+ Command halt function can handle command cooldown and errors. Return `true` if the error or cooldown is handled.
185
+
186
+ ```js
187
+ new SlashCommandBuilder()
188
+ .setName('ping')
189
+ .setDescription('Just a ping command')
190
+ .setExecute(async ({ interaction }) => {
191
+ await interaction.reply('Pong');
192
+ })
193
+ .setHalt(async haltData => {
194
+ switch (haltData.reason) {
195
+ case CommandHaltReason.Cooldown:
196
+ await haltData.executeData.interaction.followUp('You\'ve been cooled-down');
197
+ return true;
198
+ case CommandHaltReason.Error:
199
+ await haltData.executeData.interaction.followUp('An error occured');
200
+ return true;
201
+ }
202
+
203
+ // The rest is unhandled
204
+ })
205
+ ```
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.7.4",
5
+ "version": "7.8.0-dev.0",
6
6
  "type": "module",
7
7
  "types": "./bin/bin.d.ts",
8
8
  "bin": "./bin/bin.js",
@@ -17,7 +17,6 @@
17
17
  },
18
18
  "files": [
19
19
  "bin",
20
- "static",
21
20
  "templates.json",
22
21
  "templates",
23
22
  "assets",
@@ -31,7 +30,7 @@
31
30
  "devDependencies": {
32
31
  "discord.js": "^14.11.0",
33
32
  "nodemon": "^2.0.22",
34
- "reciple": "^7.6.4"
33
+ "reciple": "^7.7.0-dev.0"
35
34
  },
36
- "gitHead": "2365f83647860ba53a4a061d760fc20b31b67ab2"
35
+ "gitHead": "f078be6936292b907b4d10e9de33920bd4ab79bf"
37
36
  }