From 1d1e5ce53a16f98d8a843010653698a63c45dbeb Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Sun, 27 Nov 2022 08:40:10 +0700 Subject: [PATCH] promise > callback. --- plugins/commands.js | 4 ++-- util/load_files.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/commands.js b/plugins/commands.js index 288703b..6c28dbe 100644 --- a/plugins/commands.js +++ b/plugins/commands.js @@ -7,8 +7,8 @@ function inject(bot, dcclient, config) { const channeldc = dcclient.channels.cache.get(config.discord.servers[bot.options.host]); bot.command_handler = {}; bot.command_handler.commands = {}; - bot.command_handler.reload = function() { - bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir)); + bot.command_handler.reload = async function() { + bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir)); }; bot.command_handler.reload(); bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector) { diff --git a/util/load_files.js b/util/load_files.js index e18e96d..5ff146d 100644 --- a/util/load_files.js +++ b/util/load_files.js @@ -1,4 +1,4 @@ -const fs = require('fs'); +const fs = require('fs/promises'); const path = require('path'); /** @@ -6,10 +6,10 @@ const path = require('path'); * @param {string} directory the directory that contains the js files * @return {Array} an array of require()ed js files */ -function loadPlugins(directory) { +async function loadPlugins(directory) { const plugins = []; - for (const filename of fs.readdirSync(directory)) { + for (const filename of await fs.readdir(directory)) { if (!filename.endsWith('.js')) continue; const filepath = path.join(directory, filename);