diff options
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 |