diff options
author | WlodekM <[email protected]> | 2024-07-03 10:21:51 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-07-03 10:21:51 +0300 |
commit | 0912c5ddb27df466ac90bafe7ca72da545259019 (patch) | |
tree | c2d4886b13a5127af92a70e2a74c75747d448bd3 /commands.js | |
parent | 908b023f60ca2eec347f68bb4f0c8a9c778278ae (diff) |
v1.2
Diffstat (limited to 'commands.js')
-rw-r--r-- | commands.js | 8 |
1 files changed, 8 insertions, 0 deletions
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 |