| 32 | } |
| 33 | |
| 34 | async function getAllFiles(directory, fileList = []) { |
| 35 | const files = await fs.readdir(directory, { withFileTypes: true }); |
| 36 | |
| 37 | for (const file of files) { |
| 38 | const filePath = path.join(directory, file.name); |
| 39 | |
| 40 | if (file.isDirectory()) { |
| 41 | if (file.name === 'modules') { |
| 42 | continue; |
| 43 | } |
| 44 | await getAllFiles(filePath, fileList); |
| 45 | } else if (file.name.endsWith('.js')) { |
| 46 | fileList.push(filePath); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return fileList; |
| 51 | } |
| 52 | |
| 53 | export async function loadCommands(client) { |
| 54 | client.commands = new Collection(); |