diff options
author | marzavec <admin@marzavec.com> | 2018-03-14 06:26:53 +0100 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2018-03-14 06:26:53 +0100 |
commit | 39ec02d3c4cb5f5980b172d30404210de2479f0f (patch) | |
tree | b837c9cfff94c62aa3de9880e4f7d07460734984 /server/src/commands/mod/kick.js | |
parent | stabilized modules and server cmd field (diff) | |
download | hackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.tar.gz hackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.zip |
Streamlined modules, server tweaks, better feedback
Diffstat (limited to '')
-rw-r--r-- | server/src/commands/mod/kick.js | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js index a730caf..f51d576 100644 --- a/server/src/commands/mod/kick.js +++ b/server/src/commands/mod/kick.js @@ -1,5 +1,5 @@ /* - + Description: Forces a change on the target socket's channel, then broadcasts event */ 'use strict'; @@ -15,16 +15,9 @@ exports.run = async (core, server, socket, data) => { } let targetNick = data.nick; - let badClient = null; - for (let client of server.clients) { - // Find badClient's socket - if (client.channel == socket.channel && client.nick == targetNick) { - badClient = client; - break; - } - } + let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); - if (!badClient) { + if (badClient.length === 0) { server.reply({ cmd: 'warn', text: 'Could not find user in channel' @@ -33,6 +26,8 @@ exports.run = async (core, server, socket, data) => { return; } + badClient = badClient[0]; + if (badClient.uType !== 'user') { server.reply({ cmd: 'warn', @@ -42,7 +37,6 @@ exports.run = async (core, server, socket, data) => { return; } - // TODO: add event to log? let newChannel = Math.random().toString(36).substr(2, 8); badClient.channel = newChannel; @@ -54,7 +48,7 @@ exports.run = async (core, server, socket, data) => { nick: targetNick }, { channel: socket.channel }); - // publicly broadcast event (TODO: should this be supressed?) + // publicly broadcast event server.broadcast({ cmd: 'info', text: `Kicked ${targetNick}` |