promise > callback.

This commit is contained in:
ChomeNS 2022-11-27 08:40:10 +07:00
parent c50e49dbd4
commit 1d1e5ce53a
2 changed files with 5 additions and 5 deletions

View file

@ -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) {

View file

@ -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);