27 lines
894 B
TypeScript
27 lines
894 B
TypeScript
import * as path from "jsr:@std/path";
|
|
|
|
export async function gatherCommandsPaths(): Promise<string[]> {
|
|
const commandsPath: string[] = [];
|
|
const foldersPath = path.join(import.meta.dirname!, "commands");
|
|
const commandsRoot = Deno.readDir(foldersPath);
|
|
|
|
for await (const entry of commandsRoot) {
|
|
if (entry.isDirectory) {
|
|
const commandsFolderPath = path.join(foldersPath, entry.name);
|
|
const commandsFiles = (
|
|
await Array.fromAsync(Deno.readDir(commandsFolderPath))
|
|
).filter((file) => file.name.endsWith(".js"));
|
|
for (const file of commandsFiles) {
|
|
const commandPath = path.join(commandsFolderPath, file.name);
|
|
|
|
commandsPath.push(commandPath);
|
|
}
|
|
} else if (entry.name !== "template.ts") {
|
|
const commandPath = path.join(foldersPath, entry.name);
|
|
|
|
commandsPath.push(commandPath);
|
|
}
|
|
}
|
|
|
|
return commandsPath;
|
|
}
|