reciple 6.0.0-dev.25 → 6.0.0-dev.26

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 -66
  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 -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 +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 -59
  15. package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +25 -25
  16. package/dist/lib/reciple/classes/managers/ModuleManager.js +176 -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 -69
  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 -104
  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 +2 -2
  46. package/resource/reciple.yml +120 -120
@@ -1,59 +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
- 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
+ "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,176 @@
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
+ 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,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();
@@ -1,30 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
4
- const discord_js_1 = require("discord.js");
5
- /**
6
- * Check if the user has permissions to execute the given command name
7
- * @param options options
8
- */
9
- function userHasCommandPermissions(options) {
10
- const command = (options.commandPermissions?.enabled ? options.commandPermissions?.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase()) : null) ?? {
11
- permissions: options.builder.requiredMemberPermissions,
12
- };
13
- if (!command.permissions.length)
14
- return true;
15
- return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
16
- }
17
- exports.userHasCommandPermissions = userHasCommandPermissions;
18
- function botHasExecutePermissions(guildOrChannel, requiredPermissions) {
19
- if (!requiredPermissions?.length)
20
- return true;
21
- let permissions = null;
22
- if (guildOrChannel instanceof discord_js_1.Guild) {
23
- permissions = guildOrChannel.members.me?.permissions ?? null;
24
- }
25
- else {
26
- permissions = guildOrChannel?.permissionsFor(guildOrChannel.client.user.id) ?? null;
27
- }
28
- return permissions ? permissions.has(requiredPermissions) : false;
29
- }
30
- exports.botHasExecutePermissions = botHasExecutePermissions;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
4
+ const discord_js_1 = require("discord.js");
5
+ /**
6
+ * Check if the user has permissions to execute the given command name
7
+ * @param options options
8
+ */
9
+ function userHasCommandPermissions(options) {
10
+ const command = (options.commandPermissions?.enabled ? options.commandPermissions?.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase()) : null) ?? {
11
+ permissions: options.builder.requiredMemberPermissions,
12
+ };
13
+ if (!command.permissions.length)
14
+ return true;
15
+ return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
16
+ }
17
+ exports.userHasCommandPermissions = userHasCommandPermissions;
18
+ function botHasExecutePermissions(guildOrChannel, requiredPermissions) {
19
+ if (!requiredPermissions?.length)
20
+ return true;
21
+ let permissions = null;
22
+ if (guildOrChannel instanceof discord_js_1.Guild) {
23
+ permissions = guildOrChannel.members.me?.permissions ?? null;
24
+ }
25
+ else {
26
+ permissions = guildOrChannel?.permissionsFor(guildOrChannel.client.user.id) ?? null;
27
+ }
28
+ return permissions ? permissions.has(requiredPermissions) : false;
29
+ }
30
+ exports.botHasExecutePermissions = botHasExecutePermissions;