reciple 6.0.0-dev.19 → 6.0.0-dev.20

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 (46) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +183 -183
  3. package/dist/lib/bin.mjs +65 -65
  4. package/dist/lib/esm.mjs +1 -1
  5. package/dist/lib/index.js +35 -35
  6. package/dist/lib/reciple/classes/RecipleClient.js +296 -296
  7. package/dist/lib/reciple/classes/RecipleConfig.js +106 -106
  8. package/dist/lib/reciple/classes/RecipleModule.js +94 -94
  9. package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +242 -242
  10. package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js +85 -85
  11. package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js +216 -216
  12. package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js +178 -172
  13. package/dist/lib/reciple/classes/managers/CommandCooldownManager.js +100 -100
  14. package/dist/lib/reciple/classes/managers/{ClientCommandManager.js → CommandManager.js} +59 -62
  15. package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +25 -25
  16. package/dist/lib/reciple/classes/managers/{ClientModuleManager.js → ModuleManager.js} +179 -183
  17. package/dist/lib/reciple/flags.js +31 -31
  18. package/dist/lib/reciple/permissions.js +30 -30
  19. package/dist/lib/reciple/types/builders.js +11 -11
  20. package/dist/lib/reciple/types/commands.js +15 -15
  21. package/dist/lib/reciple/types/paramOptions.js +2 -2
  22. package/dist/lib/reciple/util.js +68 -68
  23. package/dist/lib/reciple/version.js +47 -47
  24. package/dist/types/bin.d.mts +2 -2
  25. package/dist/types/esm.d.mts +1 -1
  26. package/dist/types/index.d.ts +19 -19
  27. package/dist/types/reciple/classes/RecipleClient.d.ts +103 -103
  28. package/dist/types/reciple/classes/RecipleConfig.d.ts +100 -100
  29. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -56
  30. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +150 -150
  31. package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +43 -43
  32. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +88 -88
  33. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +53 -51
  34. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +70 -70
  35. package/dist/types/reciple/classes/managers/{ClientCommandManager.d.ts → CommandManager.d.ts} +36 -37
  36. package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +22 -22
  37. package/dist/types/reciple/classes/managers/{ClientModuleManager.d.ts → ModuleManager.d.ts} +49 -49
  38. package/dist/types/reciple/flags.d.ts +17 -17
  39. package/dist/types/reciple/permissions.d.ts +19 -19
  40. package/dist/types/reciple/types/builders.d.ts +197 -197
  41. package/dist/types/reciple/types/commands.d.ts +81 -81
  42. package/dist/types/reciple/types/paramOptions.d.ts +101 -101
  43. package/dist/types/reciple/util.d.ts +23 -23
  44. package/dist/types/reciple/version.d.ts +25 -25
  45. package/package.json +1 -1
  46. package/resource/reciple.yml +120 -120
@@ -1,62 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientCommandManager = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const builders_1 = require("../../types/builders");
6
- const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
7
- const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
8
- class ClientCommandManager {
9
- constructor(options) {
10
- this.slashCommands = new discord_js_1.Collection();
11
- this.messageCommands = new discord_js_1.Collection();
12
- this.additionalApplicationCommands = [];
13
- this.client = options.client;
14
- options.slashCommands?.forEach(e => this.slashCommands.set(e.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(e)));
15
- options.messageCommands?.forEach(e => this.messageCommands.set(e.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(e)));
16
- }
17
- get applicationCommandsSize() {
18
- return this.client.commands.slashCommands.size + this.client.commands.additionalApplicationCommands.length;
19
- }
20
- /**
21
- * Add command to command manager
22
- * @param commands Any command data or builder
23
- */
24
- add(...commands) {
25
- for (const command of (0, discord_js_1.normalizeArray)(commands)) {
26
- if (command.type === builders_1.CommandType.SlashCommand) {
27
- this.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
28
- }
29
- else if (command.type === builders_1.CommandType.MessageCommand) {
30
- this.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
31
- }
32
- else {
33
- throw new Error(`Unknown reciple command type`);
34
- }
35
- }
36
- return this;
37
- }
38
- get(command, type) {
39
- switch (type) {
40
- case builders_1.CommandType.SlashCommand:
41
- return this.slashCommands.get(command);
42
- case builders_1.CommandType.MessageCommand:
43
- return this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined);
44
- default:
45
- throw new TypeError('Unknown command type');
46
- }
47
- }
48
- /**
49
- * Register application commands
50
- * @param guilds Register application commands to guilds
51
- */
52
- async registerApplicationCommands(...guilds) {
53
- guilds = (0, discord_js_1.normalizeArray)(guilds);
54
- guilds = guilds.length ? guilds : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
55
- if (!this.client.isClientLogsSilent)
56
- this.client.logger.log(`Regestering ${this.applicationCommandsSize} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
57
- await this.client.applicationCommands.set([...this.slashCommands.toJSON(), ...this.additionalApplicationCommands], guilds);
58
- this.client.emit('recipleRegisterApplicationCommands');
59
- return this;
60
- }
61
- }
62
- exports.ClientCommandManager = ClientCommandManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandManager = void 0;
4
+ const discord_js_1 = require("discord.js");
5
+ const builders_1 = require("../../types/builders");
6
+ const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
7
+ const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
8
+ class CommandManager {
9
+ constructor(options) {
10
+ this.slashCommands = new discord_js_1.Collection();
11
+ this.messageCommands = new discord_js_1.Collection();
12
+ this.additionalApplicationCommands = [];
13
+ this.client = options.client;
14
+ options.slashCommands?.forEach(e => this.slashCommands.set(e.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(e)));
15
+ options.messageCommands?.forEach(e => this.messageCommands.set(e.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(e)));
16
+ }
17
+ /**
18
+ * Add command to command manager
19
+ * @param commands Any command data or builder
20
+ */
21
+ add(...commands) {
22
+ for (const command of (0, discord_js_1.normalizeArray)(commands)) {
23
+ if (command.type === builders_1.CommandType.SlashCommand) {
24
+ this.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
25
+ }
26
+ else if (command.type === builders_1.CommandType.MessageCommand) {
27
+ this.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
28
+ }
29
+ else {
30
+ throw new Error(`Unknown reciple command type`);
31
+ }
32
+ }
33
+ return this;
34
+ }
35
+ get(command, type) {
36
+ switch (type) {
37
+ case builders_1.CommandType.SlashCommand:
38
+ return this.slashCommands.get(command);
39
+ case builders_1.CommandType.MessageCommand:
40
+ return this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined);
41
+ default:
42
+ throw new TypeError('Unknown command type');
43
+ }
44
+ }
45
+ /**
46
+ * Register application commands
47
+ * @param guilds Register application commands to guilds
48
+ */
49
+ async registerApplicationCommands(...guilds) {
50
+ guilds = (0, discord_js_1.normalizeArray)(guilds);
51
+ guilds = guilds.length ? guilds : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
52
+ if (!this.client.isClientLogsSilent)
53
+ this.client.logger.log(`Regestering ${this.client.applicationCommands.size} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
54
+ await this.client.applicationCommands.set([...this.client.applicationCommands.commands], guilds);
55
+ this.client.emit('recipleRegisterApplicationCommands');
56
+ return this;
57
+ }
58
+ }
59
+ exports.CommandManager = CommandManager;
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageCommandOptionManager = void 0;
4
- const discord_js_1 = require("discord.js");
5
- /**
6
- * Validated message options manager
7
- */
8
- class MessageCommandOptionManager extends Array {
9
- constructor(...data) {
10
- super(...(0, discord_js_1.normalizeArray)(data));
11
- }
12
- get(name, required) {
13
- const option = this.find(o => o.name == name);
14
- if (!option?.value == undefined && required)
15
- throw new TypeError(`Can't find option named ${name}`);
16
- return option ?? null;
17
- }
18
- getValue(name, requied) {
19
- const option = this.get(name, requied);
20
- if (!option?.value && requied)
21
- throw new TypeError(`Value of option named ${name} is undefined`);
22
- return option?.value ?? null;
23
- }
24
- }
25
- exports.MessageCommandOptionManager = MessageCommandOptionManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageCommandOptionManager = void 0;
4
+ const discord_js_1 = require("discord.js");
5
+ /**
6
+ * Validated message options manager
7
+ */
8
+ class MessageCommandOptionManager extends Array {
9
+ constructor(...data) {
10
+ super(...(0, discord_js_1.normalizeArray)(data));
11
+ }
12
+ get(name, required) {
13
+ const option = this.find(o => o.name == name);
14
+ if (!option?.value == undefined && required)
15
+ throw new TypeError(`Can't find option named ${name}`);
16
+ return option ?? null;
17
+ }
18
+ getValue(name, requied) {
19
+ const option = this.get(name, requied);
20
+ if (!option?.value && requied)
21
+ throw new TypeError(`Value of option named ${name} is undefined`);
22
+ return option?.value ?? null;
23
+ }
24
+ }
25
+ exports.MessageCommandOptionManager = MessageCommandOptionManager;
@@ -1,183 +1,179 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ClientModuleManager = void 0;
7
- const discord_js_1 = require("discord.js");
8
- const fs_1 = require("fs");
9
- const util_1 = require("util");
10
- const wildcard_match_1 = __importDefault(require("wildcard-match"));
11
- const RecipleModule_1 = require("../RecipleModule");
12
- const util_2 = require("../../util");
13
- class ClientModuleManager {
14
- constructor(options) {
15
- this.modules = new discord_js_1.Collection();
16
- this.client = options.client;
17
- options.modules?.forEach(m => (m instanceof RecipleModule_1.RecipleModule ? m : new RecipleModule_1.RecipleModule({ client: this.client, script: m })));
18
- }
19
- /**
20
- * Start modules
21
- * @param options start modules options
22
- * @returns started modules
23
- */
24
- async startModules(options) {
25
- const startedModules = [];
26
- for (const module_ of options.modules) {
27
- if (!this.client.isClientLogsSilent)
28
- this.client.logger.log(`Starting module '${module_}'`);
29
- try {
30
- let error;
31
- const start = await module_.start().catch(err => {
32
- error = err;
33
- return false;
34
- });
35
- if (error)
36
- throw new Error(`An error occured while loading module '${module_}': \n${(0, util_1.inspect)(error)}`);
37
- if (!start) {
38
- if (!this.client.isClientLogsSilent)
39
- this.client.logger.error(`Module '${module_}' returned false onStart`);
40
- continue;
41
- }
42
- if (options.addToModulesCollection !== false)
43
- this.modules.set(module_.id, module_);
44
- startedModules.push(module_);
45
- }
46
- catch (err) {
47
- if (options?.ignoreErrors === false)
48
- throw err;
49
- if (!this.client.isClientLogsSilent)
50
- this.client.logger.error(`Failed to start module '${module_}': `, err);
51
- }
52
- }
53
- return startedModules;
54
- }
55
- /**
56
- * Load modules
57
- * @param options load modules options
58
- * @returns loaded modules
59
- */
60
- async loadModules(options) {
61
- const loadedModules = [];
62
- for (const module_ of options?.modules ?? this.modules.toJSON()) {
63
- try {
64
- await module_.load().catch(err => {
65
- throw err;
66
- });
67
- if (options?.resolveCommands !== false) {
68
- module_.resolveCommands();
69
- this.client.commands.add(module_.commands);
70
- }
71
- loadedModules.push(module_);
72
- if (!this.client.isClientLogsSilent)
73
- this.client.logger.log(`Loaded module '${module_}'`);
74
- }
75
- catch (err) {
76
- if (options?.ignoreErrors === false)
77
- throw err;
78
- if (!this.client.isClientLogsSilent)
79
- this.client.logger.error(`Failed to load module '${module_}': `, err);
80
- }
81
- }
82
- return loadedModules;
83
- }
84
- /**
85
- * Unload modules
86
- * @param options unload modules options
87
- * @returns unloaded modules
88
- */
89
- async unloadModules(options) {
90
- const unloadedModules = [];
91
- for (const module_ of options?.modules ?? this.modules.toJSON()) {
92
- try {
93
- await module_.unload().catch(err => {
94
- throw err;
95
- });
96
- unloadedModules.push(module_);
97
- if (!this.client.isClientLogsSilent)
98
- this.client.logger.log(`Unloaded module '${module_}'`);
99
- }
100
- catch (err) {
101
- if (options?.ignoreErrors === false)
102
- throw err;
103
- if (!this.client.isClientLogsSilent)
104
- this.client.logger.error(`Failed to unLoad module '${module_}': `, err);
105
- }
106
- }
107
- return unloadedModules;
108
- }
109
- /**
110
- * Resolve modules from file paths
111
- * @param options resolve module files options
112
- * @returns resolved modules
113
- */
114
- async resolveModuleFiles(options) {
115
- const modules = [];
116
- for (const file of options.files) {
117
- try {
118
- const resolveFile = await import((util_2.path.isAbsolute(file) ? 'file://' : '') + file);
119
- let script = resolveFile instanceof RecipleModule_1.RecipleModule || ClientModuleManager.validateScript(resolveFile)
120
- ? resolveFile
121
- : resolveFile?.default?.default instanceof RecipleModule_1.RecipleModule || ClientModuleManager.validateScript(resolveFile?.default?.default)
122
- ? resolveFile.default.default
123
- : resolveFile?.default;
124
- if (script instanceof RecipleModule_1.RecipleModule) {
125
- modules.push(script);
126
- continue;
127
- }
128
- if (!ClientModuleManager.validateScript(script))
129
- throw new Error(`Invalid module script: ${file}`);
130
- modules.push(new RecipleModule_1.RecipleModule({
131
- client: this.client,
132
- script,
133
- filePath: file,
134
- }));
135
- }
136
- catch (err) {
137
- if (options.ignoreErrors === false)
138
- throw err;
139
- if (!this.client.isClientLogsSilent)
140
- this.client.logger.error(`Can't resolve module from: ${file}`, err);
141
- }
142
- }
143
- return modules;
144
- }
145
- /**
146
- * Validate module script
147
- * @param script module script
148
- * @returns `true` if script is valid
149
- */
150
- static validateScript(script) {
151
- const s = script;
152
- if (typeof s !== 'object')
153
- return false;
154
- if (typeof s.versions !== 'string' && !Array.isArray(s.versions))
155
- return false;
156
- if (typeof s.onStart !== 'function')
157
- return false;
158
- if (s.onLoad && typeof s.onLoad !== 'function')
159
- return false;
160
- if (s.onUnload && typeof s.onUnload !== 'function')
161
- return false;
162
- return true;
163
- }
164
- /**
165
- * Get module file paths from folders
166
- * @param options get module paths options
167
- * @returns module paths
168
- */
169
- async getModulePaths(options) {
170
- const modules = [];
171
- for (const dir of options?.folders ?? (0, discord_js_1.normalizeArray)([this.client.config.modulesFolder])) {
172
- if (!(0, fs_1.existsSync)(dir))
173
- (0, fs_1.mkdirSync)(dir, { recursive: true });
174
- if (!(0, fs_1.lstatSync)(dir).isDirectory())
175
- continue;
176
- modules.push(...(0, fs_1.readdirSync)(dir)
177
- .map(file => util_2.path.join(!dir.startsWith('/') ? this.client.cwd : '', dir, file))
178
- .filter(file => (options?.filter ? options.filter(file) : file.endsWith('.js'))));
179
- }
180
- return modules.filter(file => !(options?.ignoredFiles ?? this.client.config.ignoredFiles).some(ignored => (0, wildcard_match_1.default)(ignored)(util_2.path.basename(file))));
181
- }
182
- }
183
- exports.ClientModuleManager = ClientModuleManager;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ModuleManager = void 0;
7
+ const discord_js_1 = require("discord.js");
8
+ const fs_1 = require("fs");
9
+ const util_1 = require("util");
10
+ const wildcard_match_1 = __importDefault(require("wildcard-match"));
11
+ const RecipleModule_1 = require("../RecipleModule");
12
+ const util_2 = require("../../util");
13
+ class ModuleManager {
14
+ constructor(options) {
15
+ this.modules = new discord_js_1.Collection();
16
+ this.client = options.client;
17
+ options.modules?.forEach(m => (m instanceof RecipleModule_1.RecipleModule ? m : new RecipleModule_1.RecipleModule({ client: this.client, script: m })));
18
+ }
19
+ /**
20
+ * Start modules
21
+ * @param options start modules options
22
+ * @returns started modules
23
+ */
24
+ async startModules(options) {
25
+ const startedModules = [];
26
+ for (const module_ of options.modules) {
27
+ if (!this.client.isClientLogsSilent)
28
+ this.client.logger.log(`Starting module '${module_}'`);
29
+ try {
30
+ let error;
31
+ const start = await module_.start().catch(err => {
32
+ error = err;
33
+ return false;
34
+ });
35
+ if (error)
36
+ throw new Error(`An error occured while loading module '${module_}': \n${(0, util_1.inspect)(error)}`);
37
+ if (!start) {
38
+ if (!this.client.isClientLogsSilent)
39
+ this.client.logger.error(`Module '${module_}' returned false onStart`);
40
+ continue;
41
+ }
42
+ if (options.addToModulesCollection !== false)
43
+ this.modules.set(module_.id, module_);
44
+ startedModules.push(module_);
45
+ }
46
+ catch (err) {
47
+ if (options?.ignoreErrors === false)
48
+ throw err;
49
+ if (!this.client.isClientLogsSilent)
50
+ this.client.logger.error(`Failed to start module '${module_}': `, err);
51
+ }
52
+ }
53
+ return startedModules;
54
+ }
55
+ /**
56
+ * Load modules
57
+ * @param options load modules options
58
+ * @returns loaded modules
59
+ */
60
+ async loadModules(options) {
61
+ const loadedModules = [];
62
+ for (const module_ of options?.modules ?? this.modules.toJSON()) {
63
+ try {
64
+ await module_.load().catch(err => {
65
+ throw err;
66
+ });
67
+ if (options?.resolveCommands !== false) {
68
+ module_.resolveCommands();
69
+ this.client.commands.add(module_.commands);
70
+ }
71
+ loadedModules.push(module_);
72
+ if (!this.client.isClientLogsSilent)
73
+ this.client.logger.log(`Loaded module '${module_}'`);
74
+ }
75
+ catch (err) {
76
+ if (options?.ignoreErrors === false)
77
+ throw err;
78
+ if (!this.client.isClientLogsSilent)
79
+ this.client.logger.error(`Failed to load module '${module_}': `, err);
80
+ }
81
+ }
82
+ return loadedModules;
83
+ }
84
+ /**
85
+ * Unload modules
86
+ * @param options unload modules options
87
+ * @returns unloaded modules
88
+ */
89
+ async unloadModules(options) {
90
+ const unloadedModules = [];
91
+ for (const module_ of options?.modules ?? this.modules.toJSON()) {
92
+ try {
93
+ await module_.unload().catch(err => {
94
+ throw err;
95
+ });
96
+ unloadedModules.push(module_);
97
+ if (!this.client.isClientLogsSilent)
98
+ this.client.logger.log(`Unloaded module '${module_}'`);
99
+ }
100
+ catch (err) {
101
+ if (options?.ignoreErrors === false)
102
+ throw err;
103
+ if (!this.client.isClientLogsSilent)
104
+ this.client.logger.error(`Failed to unLoad module '${module_}': `, err);
105
+ }
106
+ }
107
+ return unloadedModules;
108
+ }
109
+ /**
110
+ * Resolve modules from file paths
111
+ * @param options resolve module files options
112
+ * @returns resolved modules
113
+ */
114
+ async resolveModuleFiles(options) {
115
+ const modules = [];
116
+ for (const file of options.files) {
117
+ try {
118
+ const resolveFile = await import((util_2.path.isAbsolute(file) ? 'file://' : '') + file);
119
+ let script = resolveFile instanceof RecipleModule_1.RecipleModule || ModuleManager.validateScript(resolveFile) ? resolveFile : resolveFile?.default?.default instanceof RecipleModule_1.RecipleModule || ModuleManager.validateScript(resolveFile?.default?.default) ? resolveFile.default.default : resolveFile?.default;
120
+ if (script instanceof RecipleModule_1.RecipleModule) {
121
+ modules.push(script);
122
+ continue;
123
+ }
124
+ if (!ModuleManager.validateScript(script))
125
+ throw new Error(`Invalid module script: ${file}`);
126
+ modules.push(new RecipleModule_1.RecipleModule({
127
+ client: this.client,
128
+ script,
129
+ filePath: file,
130
+ }));
131
+ }
132
+ catch (err) {
133
+ if (options.ignoreErrors === false)
134
+ throw err;
135
+ if (!this.client.isClientLogsSilent)
136
+ this.client.logger.error(`Can't resolve module from: ${file}`, err);
137
+ }
138
+ }
139
+ return modules;
140
+ }
141
+ /**
142
+ * Validate module script
143
+ * @param script module script
144
+ * @returns `true` if script is valid
145
+ */
146
+ static validateScript(script) {
147
+ const s = script;
148
+ if (typeof s !== 'object')
149
+ return false;
150
+ if (typeof s.versions !== 'string' && !Array.isArray(s.versions))
151
+ return false;
152
+ if (typeof s.onStart !== 'function')
153
+ return false;
154
+ if (s.onLoad && typeof s.onLoad !== 'function')
155
+ return false;
156
+ if (s.onUnload && typeof s.onUnload !== 'function')
157
+ return false;
158
+ return true;
159
+ }
160
+ /**
161
+ * Get module file paths from folders
162
+ * @param options get module paths options
163
+ * @returns module paths
164
+ */
165
+ async getModulePaths(options) {
166
+ const modules = [];
167
+ for (const dir of options?.folders ?? (0, discord_js_1.normalizeArray)([this.client.config.modulesFolder])) {
168
+ if (!(0, fs_1.existsSync)(dir))
169
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
170
+ if (!(0, fs_1.lstatSync)(dir).isDirectory())
171
+ continue;
172
+ modules.push(...(0, fs_1.readdirSync)(dir)
173
+ .map(file => util_2.path.join(!dir.startsWith('/') ? this.client.cwd : '', dir, file))
174
+ .filter(file => (options?.filter ? options.filter(file) : file.endsWith('.js'))));
175
+ }
176
+ return modules.filter(file => !(options?.ignoredFiles ?? this.client.config.ignoredFiles).some(ignored => (0, wildcard_match_1.default)(ignored)(util_2.path.basename(file))));
177
+ }
178
+ }
179
+ exports.ModuleManager = ModuleManager;
@@ -1,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cwd = exports.token = exports.flags = exports.commander = void 0;
4
- const version_js_1 = require("./version.js");
5
- const commander_1 = require("commander");
6
- /**
7
- * Commander
8
- */
9
- exports.commander = new commander_1.Command()
10
- .name('reciple')
11
- .description('Reciple.js - Discord.js handler cli')
12
- .version(`v${version_js_1.rawVersion}`, '-v, --version')
13
- .argument('[current-working-directory]', 'Change the current working directory')
14
- .option('-t, --token <token>', 'Replace used bot token')
15
- .option('-c, --config <config>', 'Change path to config file')
16
- .option('-D, --debugmode', 'Enable debug mode')
17
- .option('-y, --yes', 'Automatically agree to Reciple confirmation prompts')
18
- .option('-v, --version', 'Display version')
19
- .parse();
20
- /**
21
- * Used flags
22
- */
23
- exports.flags = exports.commander.opts();
24
- /**
25
- * Token flag
26
- */
27
- exports.token = exports.flags.token;
28
- /**
29
- * Current working directory
30
- */
31
- exports.cwd = exports.commander.args[0] || process.cwd();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cwd = exports.token = exports.flags = exports.commander = void 0;
4
+ const version_js_1 = require("./version.js");
5
+ const commander_1 = require("commander");
6
+ /**
7
+ * Commander
8
+ */
9
+ exports.commander = new commander_1.Command()
10
+ .name('reciple')
11
+ .description('Reciple.js - Discord.js handler cli')
12
+ .version(`v${version_js_1.rawVersion}`, '-v, --version')
13
+ .argument('[current-working-directory]', 'Change the current working directory')
14
+ .option('-t, --token <token>', 'Replace used bot token')
15
+ .option('-c, --config <config>', 'Change path to config file')
16
+ .option('-D, --debugmode', 'Enable debug mode')
17
+ .option('-y, --yes', 'Automatically agree to Reciple confirmation prompts')
18
+ .option('-v, --version', 'Display version')
19
+ .parse();
20
+ /**
21
+ * Used flags
22
+ */
23
+ exports.flags = exports.commander.opts();
24
+ /**
25
+ * Token flag
26
+ */
27
+ exports.token = exports.flags.token;
28
+ /**
29
+ * Current working directory
30
+ */
31
+ exports.cwd = exports.commander.args[0] || process.cwd();