From 0912c5ddb27df466ac90bafe7ca72da545259019 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Wed, 3 Jul 2024 10:21:51 +0300 Subject: v1.2 --- commands.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'commands.js') diff --git a/commands.js b/commands.js index 8aa80a3..5c7a440 100644 --- a/commands.js +++ b/commands.js @@ -10,6 +10,7 @@ export const commands = { if(!server.channels.includes(args[0].replace("#", ""))) return user.socket.send("Error: Channel not found, run /channels to see a list of channels."); sendInChannel(`${user.username} left #${user.channel}.`, user.channel) user.channel = args[0].replace("#", ""); + console.info(`${user.username} went to #${user.channel}`) sendInChannel(`${user.username} joined #${user.channel}!`, user.channel) } }, @@ -68,4 +69,11 @@ export const commands = { export function register(cmd, data) { commands[cmd] = data +} + +let commandFiles = fs.readdirSync("commands").filter(filename => filename.endsWith(".js")).map(file => file.replace(/\.js$/gmi, '')) +for (let i = 0; i < commandFiles.length; i++) { + const cmdName = commandFiles[i]; + const cmd = (await import(`./commands/${cmdName}.js`)).default + register(cmdName, cmd) } \ No newline at end of file -- cgit 1.4.1-2-gfad0