reciple 6.0.0-dev.26 → 6.0.0-dev.27

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