clean up: fs.promises api and reformat

This commit is contained in:
Baipyrus 2024-02-06 14:09:04 +01:00
parent fdedb50bc5
commit 46e938946c

View File

@ -1,13 +1,11 @@
import { Client, Collection, GatewayIntentBits } from 'discord.js';
import { readdir, stat } from 'fs/promises';
import { Partials } from 'discord.js';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { promisify } from 'util';
import { config } from 'dotenv';
import { readdir } from 'fs';
import { Partials } from 'discord.js';
config();
const readdirAsync = promisify(readdir);
const required = ['data', 'execute'];
const optional = ['autocomplete', 'modalSubmit'];
@ -39,14 +37,13 @@ const runClient = (commands, events) => {
const __dirname = dirname(fileURLToPath(import.meta.url));
const cmdPath = join(__dirname, 'commands');
const evtPath = join(__dirname, 'events');
readdirAsync(cmdPath)
.then(
async (categories) =>
readdir(cmdPath)
.then(async (categories) =>
// For each category directory
await Promise.all(
categories.map(async (category) => {
const catPath = join(cmdPath, category);
const content = await readdirAsync(catPath);
const content = await readdir(catPath);
const files = content.filter((file) => file.endsWith('.js') && !file.endsWith('.example.js'));
// For each command file
return await Promise.all(
@ -73,10 +70,10 @@ readdirAsync(cmdPath)
);
})
)
)
.then((commands) => commands.reduce((a, i) => a.concat(i), []).filter((e) => e !== 0))
.then(async (commands) => {
const content = await readdirAsync(evtPath);
).then((commands) =>
commands.reduce((a, i) => a.concat(i), []).filter((e) => e !== 0)
).then(async (commands) => {
const content = await readdir(evtPath);
const files = content.filter((file) => file.endsWith('.js'));
const events = await Promise.all(
files.map(async (current) => {