From 424d5ab02aea10cc1b13bf61e84b57a21db2c291 Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 28 Sep 2022 16:05:07 +0200 Subject: [PATCH] Don't hardcode the folders --- index.js | 11 +++++------ scripts/deploy-commands.js | 10 ++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 72d1ef26..d52769e6 100644 --- a/index.js +++ b/index.js @@ -17,12 +17,11 @@ const client = new Client({ // Load commands client.commands = new Collection(); -await loadCommandFromDir('fun'); -await loadCommandFromDir('secret'); -await loadCommandFromDir('utility'); -await loadCommandFromDir('voice'); -await loadCommandFromDir('admin'); -await loadCommandFromDir('owner'); + +const categoryPath = fs.readdirSync(`${__dirname}/commands`); +categoryPath.forEach(category => { + loadCommandFromDir(category); +}); // Load events await loadEventFromDir('client', client); diff --git a/scripts/deploy-commands.js b/scripts/deploy-commands.js index 2f7bb0b1..c5e19e7c 100644 --- a/scripts/deploy-commands.js +++ b/scripts/deploy-commands.js @@ -11,12 +11,10 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const commands = []; -await loadCommandFromDir('fun'); -await loadCommandFromDir('secret'); -await loadCommandFromDir('utility'); -await loadCommandFromDir('voice'); -await loadCommandFromDir('admin'); -await loadCommandFromDir('owner'); +const categoryPath = fs.readdirSync(`${__dirname}/../commands`); +categoryPath.forEach(category => { + loadCommandFromDir(category); +}); commands.map(command => command.toJSON()); const rest = new REST({ version: '9' }).setToken(token);