Refactor command and event loading

This commit is contained in:
2026-01-26 11:34:48 +01:00
parent 0d265b0fb5
commit 7662337553
4 changed files with 100 additions and 56 deletions
+23
View File
@@ -0,0 +1,23 @@
const fs = require('node:fs');
const path = require('node:path');
const isJavaScriptFile = (file) => file.endsWith('.js');
const getEventFilePaths = (eventsPath) =>
fs
.readdirSync(eventsPath)
.filter(isJavaScriptFile)
.map((file) => path.join(eventsPath, file));
const loadEventModules = (eventsPath) => {
const eventFiles = getEventFilePaths(eventsPath);
return eventFiles.map((filePath) => ({
filePath,
event: require(filePath),
}));
};
module.exports = {
loadEventModules,
};