()
| 46 | }); |
| 47 | } |
| 48 | async loadCommands() { |
| 49 | const pluginsPath = path.join(process.cwd(), 'plugins'); |
| 50 | const files = fs.readdirSync(pluginsPath).filter(f => f.endsWith('.js')); |
| 51 | for (const file of files) { |
| 52 | try { |
| 53 | const filePath = path.join(pluginsPath, file); |
| 54 | const plugin = (await import(pathToFileURL(filePath).href)).default || (await import(pathToFileURL(filePath).href)); |
| 55 | if (plugin.command) { |
| 56 | this.registerCommand(plugin); |
| 57 | if (plugin.isPrefixless === true) { |
| 58 | const cmdKey = plugin.command.toLowerCase(); |
| 59 | this.prefixlessCommands.set(cmdKey, cmdKey); |
| 60 | if (plugin.aliases && Array.isArray(plugin.aliases)) { |
| 61 | plugin.aliases.forEach((alias) => { |
| 62 | this.prefixlessCommands.set(alias.toLowerCase(), cmdKey); |
| 63 | }); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | catch (error) { |
| 69 | console.error(`Error loading ${file}:`, error.message); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | registerCommand(plugin) { |
| 74 | const { command, aliases = [], category = 'misc', handler } = plugin; |
| 75 | if (!command || typeof handler !== 'function') { |
no test coverage detected