diff --git a/index.js b/index.js index 6a65a93..2405abf 100644 --- a/index.js +++ b/index.js @@ -108,15 +108,12 @@ client.addListener('registered', () => { const args = split[1].split(' ')[1] ? split[1].split(' ')[1] : "" switch (terminalCommand) { case "switch_channel": - console.log("Received args:", args); if (!args) { console.log("Arguments required"); break } - if (!settings.client.chans.includes(args)) { - console.log(`You're not in that channel!`); - break - } + console.log(client.chans) + if(!checkIfIsInChannelAndLog(args)) break currentChannel = args; console.log("Current Channel set to:", currentChannel); break; @@ -126,13 +123,9 @@ client.addListener('registered', () => { case "get_users": let channel = currentChannel if(args){ - if (!settings.channels.includes(args)){ - console.log("You're not in that channel!") - break - } + if(!checkIfIsInChannelAndLog(channel)) break channel = args } - console.log(client.chans[channel]) for (user in client.chans[channel].users){ console.log(user) } @@ -147,4 +140,12 @@ client.addListener('registered', () => { rl.prompt(); messagePrompt() -}) \ No newline at end of file +}) + +function checkIfIsInChannelAndLog(channel){ + if(!client.chans[channel]){ + console.log(`You're not in that channel!`); + return false + } + return true +} \ No newline at end of file