diff --git a/src/buttons/loader.ts b/src/buttons/loader.ts index c93897c..ef3823b 100644 --- a/src/buttons/loader.ts +++ b/src/buttons/loader.ts @@ -1,5 +1,5 @@ import { readdir } from "fs/promises"; -import { removeExtension, splitFilenameExtensions } from "../utils/misc"; +import { removeExtension } from "../utils/misc"; import { ChatInputCommandInteraction, Client, @@ -10,9 +10,9 @@ import { getLocale } from "../utils/locales"; export default async (client: Client) => { // Dossier des buttons - const buttons_categories = (await readdir(__dirname)).filter( - (element) => splitFilenameExtensions(element)?.ext === undefined, - ); + const buttons_categories = (await readdir(__dirname, { withFileTypes: true })) + .filter((element) => element.isDirectory()) + .map((element) => element.name); await Promise.all( // For each categorie diff --git a/src/commands/loader.ts b/src/commands/loader.ts index 419bef4..b8b1c24 100644 --- a/src/commands/loader.ts +++ b/src/commands/loader.ts @@ -2,15 +2,15 @@ import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; import { Client } from "discord.js"; import { readdir } from "fs/promises"; -import { removeExtension, splitFilenameExtensions } from "../utils/misc"; +import { removeExtension } from "../utils/misc"; /** Load all the commands */ export default async (client: Client) => { const rest = new REST({ version: "10" }).setToken(client.token!); - const command_categories = (await readdir(__dirname)).filter( - (element) => splitFilenameExtensions(element)?.ext === undefined, - ); + const command_categories = (await readdir(__dirname, { withFileTypes: true })) + .filter((element) => element.isDirectory()) + .map((element) => element.name); const commands = ( await Promise.all( diff --git a/src/events/loader.ts b/src/events/loader.ts index 733784c..5557ccf 100644 --- a/src/events/loader.ts +++ b/src/events/loader.ts @@ -5,9 +5,9 @@ import { splitFilenameExtensions } from "../utils/misc"; /** Load all the events */ export default async (client: Client, isDev: boolean) => { - const events_categories = (await readdir(__dirname)).filter( - (element) => splitFilenameExtensions(element)?.ext === undefined, - ); + const events_categories = (await readdir(__dirname, { withFileTypes: true })) + .filter((element) => element.isDirectory()) + .map((element) => element.name); const player = useMainPlayer();