create-reciple 7.11.14 → 8.0.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 (52) hide show
  1. package/dist/bin.d.ts +1 -0
  2. package/dist/bin.js +104 -0
  3. package/dist/bin.js.map +1 -0
  4. package/dist/index.d.ts +3 -0
  5. package/dist/index.js +4 -0
  6. package/dist/index.js.map +1 -0
  7. package/{bin → dist}/utils/constants.d.ts +15 -7
  8. package/dist/utils/constants.js +60 -0
  9. package/dist/utils/constants.js.map +1 -0
  10. package/dist/utils/helpers.d.ts +12 -0
  11. package/dist/utils/helpers.js +103 -0
  12. package/dist/utils/helpers.js.map +1 -0
  13. package/dist/utils/types.d.ts +19 -0
  14. package/package.json +19 -12
  15. package/templates/{javascript-esm → cjs}/dot.gitignore +130 -130
  16. package/templates/cjs/modules/example.js +49 -0
  17. package/templates/{javascript → cjs}/package.json +3 -2
  18. package/templates/cjs/template.json +4 -0
  19. package/templates/{javascript → cts}/dot.gitignore +133 -130
  20. package/templates/{typescript → cts}/package.json +20 -19
  21. package/templates/cts/src/example.ts +44 -0
  22. package/templates/cts/template.json +4 -0
  23. package/templates/{typescript → cts}/tsconfig.json +13 -13
  24. package/templates/{typescript → mjs}/dot.gitignore +130 -133
  25. package/templates/mjs/modules/example.js +47 -0
  26. package/templates/{javascript-esm → mjs}/package.json +3 -3
  27. package/templates/mjs/template.json +4 -0
  28. package/templates/{typescript-esm → mts}/dot.gitignore +133 -133
  29. package/templates/{typescript-esm → mts}/package.json +20 -20
  30. package/templates/mts/src/example.ts +44 -0
  31. package/templates/mts/template.json +4 -0
  32. package/templates/{typescript-esm → mts}/tsconfig.json +13 -13
  33. package/assets/README.md +0 -257
  34. package/bin/bin.d.ts +0 -2
  35. package/bin/bin.js +0 -95
  36. package/bin/bin.js.map +0 -1
  37. package/bin/create.d.ts +0 -2
  38. package/bin/create.js +0 -44
  39. package/bin/create.js.map +0 -1
  40. package/bin/utils/constants.js +0 -39
  41. package/bin/utils/constants.js.map +0 -1
  42. package/bin/utils/functions.d.ts +0 -3
  43. package/bin/utils/functions.js +0 -20
  44. package/bin/utils/functions.js.map +0 -1
  45. package/bin/utils/types.d.ts +0 -1
  46. package/templates/javascript/modules/example.js +0 -40
  47. package/templates/javascript-esm/modules/example.js +0 -40
  48. package/templates/typescript/src/example.ts +0 -43
  49. package/templates/typescript-esm/src/example.ts +0 -43
  50. package/templates.json +0 -12
  51. /package/{bin → dist}/utils/types.js +0 -0
  52. /package/{bin → dist}/utils/types.js.map +0 -0
@@ -0,0 +1,44 @@
1
+ import { SlashCommandBuilder, ContextMenuCommandBuilder, MessageCommandBuilder, RecipleModuleData } from 'reciple';
2
+
3
+ export default {
4
+ // Supported client versions
5
+ versions: ['^8'],
6
+
7
+ // Module commands
8
+ commands: [
9
+ new ContextMenuCommandBuilder()
10
+ .setName('test')
11
+ .setType('Message')
12
+ .setExecute(async ({ interaction }) => {
13
+ await interaction.reply(`Hello, world!`);
14
+ }),
15
+ new MessageCommandBuilder()
16
+ .setName('test')
17
+ .setDescription('A test command')
18
+ .setExecute(async ({ message }) => {
19
+ await message.reply(`Hello, world!`);
20
+ }),
21
+ new SlashCommandBuilder()
22
+ .setName('test')
23
+ .setDescription('A test command')
24
+ .setExecute(async ({ interaction }) => {
25
+ await interaction.reply(`Hello, world!`);
26
+ })
27
+ ],
28
+
29
+ // Executed when module is started (Bot is not logged in)
30
+ onStart: ({ client }) => {
31
+ return true; // Return true when the module is loaded, false if not
32
+ },
33
+
34
+ // Executed when module is loaded (Bot is logged in)
35
+ onLoad: ({ client }) => {
36
+ // Return/throw a string or error on load fail
37
+ },
38
+
39
+
40
+ // Executed when module is unloaded
41
+ onUnload: ({ client }) => {
42
+ // Return/throw a string or error on unload fail
43
+ }
44
+ } satisfies RecipleModuleData;
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "Typescript - ES Modules",
3
+ "language": "Typescript"
4
+ }
@@ -1,14 +1,14 @@
1
- {
2
- "include": ["./src/**/*"],
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./modules",
6
- "target": "ES2020",
7
- "module": "Node16",
8
- "moduleResolution": "node16",
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "sourceMap": true,
12
- "strict": true
13
- }
1
+ {
2
+ "include": ["./src/**/*"],
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./modules",
6
+ "target": "ESNext",
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext",
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "sourceMap": true,
12
+ "strict": true
13
+ }
14
14
  }
package/assets/README.md DELETED
@@ -1,257 +0,0 @@
1
- ## Reciple App
2
-
3
- This application is generated from [`create-reciple`](https://npm.im/create-reciple) templates. Reciple is a [Discord.js](https://discord.js.org) command handler framework that just works.
4
-
5
- ## Reciple Modules
6
-
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
9
-
10
- ### Folder Structure
11
-
12
- ##### Example Structure
13
- ```yml
14
- # Modules config
15
-
16
- modules:
17
- modulesFolders:
18
- - './modules' # Scans the modules folder for module files
19
- ```
20
-
21
- ```
22
- # Dir structure
23
-
24
- modules/
25
- ├─ Module1.js
26
- ├─ Module2.js
27
- ```
28
-
29
- ##### Example Structure with Glob patterns
30
- ```yml
31
- # Modules config
32
-
33
- modules:
34
- modulesFolders:
35
- - './modules' # Scans the modules folder for module files
36
- - './modules/*' # Scans the folders of modules folder for module files
37
- ```
38
-
39
- ```
40
- # Dir structure
41
-
42
- modules/
43
- ├─ moreModules/
44
- │ ├─ Module1.js
45
- │ ├─ Module2.js
46
- ├─ Module3.js
47
- ├─ Module4.js
48
- ```
49
-
50
- ### Module Structure
51
-
52
- Module files can be ES Modules or CommonJs.
53
-
54
- ##### Supported module file types
55
-
56
- - `.js` *This can be an ESM or CJS*
57
- - `.mjs`
58
- - `.cjs`
59
-
60
- #### Module file structure
61
-
62
- - [RecipleModuleScript](https://reciple.js.org/docs/client/main/typedefs/RecipleModuleScript)
63
-
64
- #### ESM module example
65
-
66
- ```js
67
- // Usage without classes
68
-
69
- export default {
70
- versions: '^7',
71
- onStart: async client => {
72
- return true;
73
- },
74
- onLoad: async client => {},
75
- onUnload: async ({ client }) => {}
76
- };
77
- ```
78
- ```js
79
- // Usage with classes
80
-
81
- export class MyModule {
82
- versions = '^7';
83
- commands = [];
84
-
85
- async onStart(client) {
86
- return true;
87
- }
88
-
89
- async onLoad(client) {}
90
- async onUnload(unloadData) {}
91
- }
92
-
93
- export default new MyModule();
94
- ```
95
-
96
- #### CommonJS module example
97
-
98
- ```js
99
- // Usage without classes
100
-
101
- module.exports = {
102
- versions: '^7',
103
- onStart: async client => {
104
- return true;
105
- },
106
- onLoad: async client => {},
107
- onUnload: async ({ client }) => {}
108
- };
109
- ```
110
- ```js
111
- // Usage with classes
112
-
113
- class MyModule {
114
- versions = '^7';
115
- commands = [];
116
-
117
- async onStart(client) {
118
- return true;
119
- }
120
-
121
- async onLoad(client) {}
122
- async onUnload(unloadData) {}
123
- }
124
-
125
- module.exports = new MyModule();
126
- ```
127
-
128
- ## Reciple Commands
129
-
130
- instead of importing builders from `discord.js`, import command builders from `reciple` or `@reciple/client`.
131
-
132
- ```diff
133
- - const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('discord.js');
134
- - import { SlashCommandBuilder, ContextMenuCommandBuilder } from 'discord.js';
135
- + const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('reciple');
136
- + import { SlashCommandBuilder, ContextMenuCommandBuilder } from 'reciple';
137
- ```
138
-
139
- You can add your commands in the commands property of your module script.
140
-
141
- ```js
142
- export default {
143
- versions: '^7',
144
- commands: [
145
- new SlashCommandBuilder()
146
- .setName('ping')
147
- .setDescription('Just a ping command')
148
- .setExecute(async ({ interaction }) => {
149
- await interaction.reply('Pong');
150
- })
151
- ],
152
- onStart: async client => {
153
- return true;
154
- }
155
- };
156
- ```
157
-
158
- ### Interaction command execute params
159
-
160
- - [ContextMenuCommandExecuteData](https://reciple.js.org/docs/client/main/typedefs/ContextMenuCommandExecuteData)
161
- - [SlashCommandExecuteData](https://reciple.js.org/docs/client/main/typedefs/SlashCommandExecuteData)
162
-
163
- ### Message command execute params
164
-
165
- - [MessageCommandExecuteData](https://reciple.js.org/docs/client/main/typedefs/MessageCommandExecuteData)
166
-
167
- ### Handling command execute errors
168
-
169
- Command halt function can handle command cooldown and errors. Return `true` if the error or cooldown is handled.
170
-
171
- ```js
172
- new SlashCommandBuilder()
173
- .setName('ping')
174
- .setDescription('Just a ping command')
175
- .setExecute(async ({ interaction }) => {
176
- await interaction.reply('Pong');
177
- })
178
- .setHalt(async haltData => {
179
- switch (haltData.reason) {
180
- case CommandHaltReason.Cooldown:
181
- await haltData.executeData.interaction.followUp(`You've been cooled-down`);
182
- return true;
183
- case CommandHaltReason.Error:
184
- await haltData.executeData.interaction.followUp('An error occured');
185
- return true;
186
- }
187
-
188
- // The rest is unhandled
189
- })
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/bin/bin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/bin/bin.js DELETED
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env node
2
- import { cancel, confirm, group, intro, isCancel, outro, select, text } from '@clack/prompts';
3
- import { resolvePackageManager } from './utils/functions.js';
4
- import { readFile, readdir, stat } from 'node:fs/promises';
5
- import { dirname, join, resolve } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
- import { create } from './create.js';
8
- import { existsSync } from 'node:fs';
9
- import { exit } from 'node:process';
10
- import kleur from 'kleur';
11
- const __filename = fileURLToPath(import.meta.url);
12
- const __dirname = dirname(__filename);
13
- const root = join(__dirname, '../');
14
- const isExplicitDir = !!process.argv[2];
15
- let cwd = resolve(process.argv[2] || '.');
16
- intro(`${kleur.bold().cyan(`Welcome to Reciple!`)}`);
17
- if (cwd === process.cwd() && !isExplicitDir) {
18
- const newCwd = await text({
19
- message: 'Set your project directory (Leave empty to use current dir)',
20
- placeholder: 'Project directory'
21
- });
22
- if (isCancel(newCwd)) {
23
- cancel('Operation cancelled');
24
- exit(1);
25
- }
26
- if (newCwd)
27
- cwd = newCwd;
28
- }
29
- if (existsSync(cwd)) {
30
- if (!(await stat(cwd)).isDirectory()) {
31
- console.log(`${kleur.gray(cwd)} ${kleur.green(`is not a directory`)}`);
32
- exit(1);
33
- }
34
- if ((await readdir(cwd)).length > 0) {
35
- const acceptDir = await confirm({
36
- message: 'Directory is not empty, would you like to continue?',
37
- initialValue: false
38
- });
39
- if (!acceptDir || isCancel(acceptDir)) {
40
- cancel('Operation cancelled');
41
- exit(1);
42
- }
43
- }
44
- }
45
- const templatesRawJSON = await readFile(join(root, 'templates.json'), 'utf-8');
46
- const packageManagers = [
47
- {
48
- label: 'npm',
49
- hint: 'Uses npm as package manager',
50
- value: 'npm'
51
- },
52
- {
53
- label: 'yarn',
54
- hint: 'Uses yarn as package manager',
55
- value: 'yarn'
56
- },
57
- {
58
- label: 'pnpm',
59
- hint: 'Uses pnpm as package manager',
60
- value: 'pnpm'
61
- },
62
- {
63
- label: 'none',
64
- hint: 'Setup package manager later',
65
- value: 'none'
66
- }
67
- ];
68
- const resolvedPackageManager = resolvePackageManager();
69
- let firstPackageManagerIndex = packageManagers.findIndex(p => resolvedPackageManager && resolvedPackageManager === p.value);
70
- firstPackageManagerIndex = firstPackageManagerIndex === -1 ? packageManagers.length - 1 : firstPackageManagerIndex;
71
- const setup = await group({
72
- template: () => select({
73
- message: 'Which language would you like to use?',
74
- // @ts-expect-error Idk why
75
- options: JSON.parse(templatesRawJSON).map(m => ({
76
- label: m.name,
77
- value: m.dir,
78
- hint: m.description
79
- }))
80
- }),
81
- esm: () => confirm({
82
- message: 'Would you like to use ES Modules? (ES modules uses import instead of require)',
83
- initialValue: false
84
- }),
85
- packageManager: () => select({
86
- message: 'Select your preferred package manager',
87
- options: [
88
- packageManagers[firstPackageManagerIndex],
89
- ...packageManagers.filter((p, i) => i !== firstPackageManagerIndex)
90
- ]
91
- }),
92
- }, { onCancel: () => { cancel('Operation cancelled'); exit(1); } });
93
- outro('Setup done!');
94
- create(cwd, join(root, setup.template), setup.esm, setup.packageManager !== 'none' ? setup.packageManager : undefined);
95
- //# sourceMappingURL=bin.js.map
package/bin/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAEpC,MAAM,aAAa,GAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEjD,IAAI,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI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,MAAM,CAA4F;QACpH,OAAO,EAAE,uCAAuC;QAChD,OAAO,EAAE;YACL,eAAe,CAAC,wBAAwB,CAAC;YACzC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,wBAAwB,CAAC;SACtE;KACJ,CAAC;CACL,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEpE,KAAK,CAAC,aAAa,CAAC,CAAC;AAErB,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC"}
package/bin/create.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { PackageManager } from './utils/types.js';
2
- export declare function create(cwd: string, templateDir: string, esm: boolean, pm?: PackageManager): Promise<void>;
package/bin/create.js DELETED
@@ -1,44 +0,0 @@
1
- import { packageManagerPlaceholders, packages, root } from './utils/constants.js';
2
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
- import { copyFile, runScript } from './utils/functions.js';
4
- import { join, relative } from 'node:path';
5
- import { existsSync } from 'node:fs';
6
- import kleur from 'kleur';
7
- export async function create(cwd, templateDir, esm, pm) {
8
- if (esm)
9
- templateDir = templateDir + `-esm`;
10
- if (!existsSync(templateDir))
11
- return;
12
- await mkdir(cwd, { recursive: true });
13
- copyFile(templateDir, cwd, f => f.replace('dot.', '.'));
14
- if (existsSync(join(root, 'assets'))) {
15
- copyFile(join(root, 'assets'), cwd, f => f.replace('dot.', '.'));
16
- }
17
- let rawPackageJSON = await readFile(join(cwd, 'package.json'), 'utf-8');
18
- const placeholders = packageManagerPlaceholders[pm ?? 'npm'];
19
- for (const pkg of Object.keys(packages)) {
20
- rawPackageJSON = rawPackageJSON.replaceAll(pkg, packages[pkg]);
21
- }
22
- for (const placeholder of Object.keys(placeholders)) {
23
- rawPackageJSON = rawPackageJSON.replaceAll(placeholder, placeholders[placeholder]);
24
- }
25
- await writeFile(join(cwd, 'package.json'), rawPackageJSON);
26
- if (pm) {
27
- await runScript(placeholders.INSTALL_ALL, cwd);
28
- if (templateDir.includes(`typescript`))
29
- await runScript(`${placeholders.SCRIPT_RUN} build`, cwd);
30
- await runScript(`${placeholders.BIN_EXEC} reciple -y --setup`, cwd);
31
- }
32
- console.log(`${kleur.bold(kleur.green('✔') + ' Your project is ready!')}`);
33
- console.log(`\nStart developing:`);
34
- if (relative(process.cwd(), cwd) !== '') {
35
- console.log(` • ${kleur.cyan().bold('cd ' + relative(process.cwd(), cwd))}`);
36
- }
37
- if (!pm) {
38
- console.log(` • ${kleur.cyan().bold(placeholders.INSTALL_ALL)} (or ${packageManagerPlaceholders.pnpm.INSTALL_ALL}, etc)`);
39
- console.log(` • ${kleur.cyan().bold(`${placeholders.BIN_EXEC} reciple --setup`)}`);
40
- }
41
- console.log(` • ${kleur.cyan().bold(`${placeholders.SCRIPT_RUN} dev`)}`);
42
- console.log(`\nTo close the bot process, press ${kleur.cyan().bold(`Ctrl + C`)}`);
43
- }
44
- //# sourceMappingURL=create.js.map
package/bin/create.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,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C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,UAAU,MAAM,CAAC,EAAE,CAAC,CAAC;IAE1E,OAAO,CAAC,GAAG,CAAC,qCAAqC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;AACrF,CAAC"}
@@ -1,39 +0,0 @@
1
- import { dirname, join } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { readFileSync } from 'node:fs';
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = dirname(__filename);
6
- export const root = join(__dirname, '../../');
7
- export const packageJSON = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));
8
- export const packages = {
9
- 'TYPES_NODE': packageJSON.devDependencies['@types/node'],
10
- 'TYPESCRIPT': packageJSON.devDependencies['typescript'],
11
- 'RIMRAF': packageJSON.devDependencies['rimraf'],
12
- 'RECIPLE': packageJSON.devDependencies['reciple'],
13
- 'DISCORDJS': packageJSON.devDependencies['discord.js'],
14
- 'NODEMON': packageJSON.devDependencies['nodemon']
15
- };
16
- export const packageManagerPlaceholders = {
17
- 'npm': {
18
- 'SCRIPT_RUN': 'npm run',
19
- 'BIN_EXEC': 'npx',
20
- 'INSTALL_ALL': 'npm install',
21
- 'INSTALL_PKG': 'npm install',
22
- 'UNINSTALL_PKG': 'npm uninstall'
23
- },
24
- 'pnpm': {
25
- 'SCRIPT_RUN': 'pnpm run',
26
- 'BIN_EXEC': 'pnpm exec',
27
- 'INSTALL_ALL': 'pnpm install',
28
- 'INSTALL_PKG': 'pnpm add',
29
- 'UNINSTALL_PKG': 'pnpm remove'
30
- },
31
- 'yarn': {
32
- 'SCRIPT_RUN': 'yarn run',
33
- 'BIN_EXEC': 'yarn exec',
34
- 'INSTALL_ALL': 'yarn',
35
- 'INSTALL_PKG': 'yarn add',
36
- 'UNINSTALL_PKG': 'yarn remove'
37
- }
38
- };
39
- //# sourceMappingURL=constants.js.map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AAa,EAAE,cAAc;QAC7B,aAAa,EAAE,UAAU;QACzB,eAAe,EAAE,aAAa;KACjC;IACD,MAAM,EAAE;QACJ,YAAY,EAAE,UAAU;QACxB,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE,MAAM;QACrB,aAAa,EAAE,UAAU;QACzB,eAAe,EAAE,aAAa;KACjC;CACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare function runScript(command: string, cwd: string, options?: string[]): Promise<void>;
2
- export { resolvePackageManager } from '@reciple/utils';
3
- export declare function copyFile(from: string, to: string, rename?: (f: string) => string): void;
@@ -1,20 +0,0 @@
1
- import { copyFileSync, lstatSync, mkdirSync, readdirSync } from 'node:fs';
2
- import { execSync } from 'node:child_process';
3
- import { dirname, join } from 'node:path';
4
- export async function runScript(command, cwd, options) {
5
- execSync(`${command}${options?.length ? (' ' + options.join(' ')) : ''}`, { cwd, env: { ...process.env, FORCE_COLOR: '1' }, stdio: ['inherit', 'inherit', 'inherit'] });
6
- }
7
- export { resolvePackageManager } from '@reciple/utils';
8
- export function copyFile(from, to, rename) {
9
- const isDirectory = lstatSync(from).isDirectory();
10
- if (isDirectory) {
11
- const contents = readdirSync(from);
12
- for (const content of contents) {
13
- copyFile(join(from, content), join(to, rename ? rename(content) : content));
14
- }
15
- return;
16
- }
17
- mkdirSync(dirname(to), { recursive: true });
18
- copyFileSync(from, to);
19
- }
20
- //# sourceMappingURL=functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/utils/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAe,EAAE,GAAW,EAAE,OAAkB;IAC5E,QAAQ,CAAC,GAAG,OAAO,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAC5K,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,EAAU,EAAE,MAA8B;IAC7E,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAElD,IAAI,WAAW,EAAE;QACb,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAEnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/E;QAED,OAAO;KACV;IAED,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC"}
@@ -1 +0,0 @@
1
- export { PackageManager } from '@reciple/utils';
@@ -1,40 +0,0 @@
1
- const { ContextMenuCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } = require('reciple');
2
- const { ApplicationCommandType } = require('discord.js');
3
-
4
- /**
5
- * @type {import('reciple').RecipleModuleScript}
6
- */
7
- module.exports = {
8
- versions: ['^7'], // Module supports reciple client version 7
9
- commands: [
10
- // Right click a message to execute command
11
- new ContextMenuCommandBuilder()
12
- .setName(`Test Context Menu`)
13
- .setType(ApplicationCommandType.Message)
14
- .setExecute(async data => data.interaction.reply(`Hello!`)),
15
-
16
- // Send !test to execute command
17
- new MessageCommandBuilder()
18
- .setName(`test`)
19
- .setDescription(`Test message command`)
20
- .setAliases(`t`)
21
- .setExecute(async data => data.message.reply(`Test message command`)),
22
-
23
- // Use /test to execute command
24
- new SlashCommandBuilder()
25
- .setName(`test`)
26
- .setDescription(`Test slash command`)
27
- .setExecute(async data => data.interaction.reply(`Test slash command`))
28
- ],
29
-
30
- // Module resolved logic here (Bot not logged in)
31
- onStart(client) {
32
- return true;
33
- },
34
-
35
- // Module loaded logic here (Bot logged in)
36
- onLoad(client, module) {},
37
-
38
- // Unload logic here
39
- onUnload({ reason, client }) {}
40
- };
@@ -1,40 +0,0 @@
1
- import { ContextMenuCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } from 'reciple';
2
- import { ApplicationCommandType } from 'discord.js';
3
-
4
- /**
5
- * @type {import('reciple').RecipleModuleScript}
6
- */
7
- export default {
8
- versions: ['^7'], // Module supports reciple client version 7
9
- commands: [
10
- // Right click a message to execute command
11
- new ContextMenuCommandBuilder()
12
- .setName(`Test Context Menu`)
13
- .setType(ApplicationCommandType.Message)
14
- .setExecute(async data => data.interaction.reply(`Hello!`)),
15
-
16
- // Send !test to execute command
17
- new MessageCommandBuilder()
18
- .setName(`test`)
19
- .setDescription(`Test message command`)
20
- .setAliases(`t`)
21
- .setExecute(async data => data.message.reply(`Test message command`)),
22
-
23
- // Use /test to execute command
24
- new SlashCommandBuilder()
25
- .setName(`test`)
26
- .setDescription(`Test slash command`)
27
- .setExecute(async data => data.interaction.reply(`Test slash command`))
28
- ],
29
-
30
- // Module resolved logic here (Bot not logged in)
31
- onStart(client) {
32
- return true;
33
- },
34
-
35
- // Module loaded logic here (Bot logged in)
36
- onLoad(client, module) {},
37
-
38
- // Unload logic here
39
- onUnload({ reason, client }) {}
40
- };