diff options
author | Neel Kamath <neelkamath@protonmail.com> | 2018-05-13 12:39:55 +0200 |
---|---|---|
committer | Neel Kamath <neelkamath@protonmail.com> | 2018-05-13 12:39:55 +0200 |
commit | 2bb5ced363b692a5696b176bc317fe525c0c05df (patch) | |
tree | 1532d9456c5f2b25ac05f7cec620a3af890eff83 /server/src/commands/mod/kick.js | |
parent | Re-add module documentation (diff) | |
download | hackchat-2bb5ced363b692a5696b176bc317fe525c0c05df.tar.gz hackchat-2bb5ced363b692a5696b176bc317fe525c0c05df.zip |
Flatten
Diffstat (limited to 'server/src/commands/mod/kick.js')
-rw-r--r-- | server/src/commands/mod/kick.js | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js deleted file mode 100644 index 157592d..0000000 --- a/server/src/commands/mod/kick.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - Description: Forces a change on the target socket's channel, then broadcasts event -*/ - -exports.run = async (core, server, socket, data) => { - if (socket.uType === 'user') { - // ignore if not mod or admin - return; - } - - if (typeof data.nick !== 'string') { - if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) { - return; - } - } - - let badClients = server.findSockets({ channel: socket.channel, nick: data.nick }); - - if (badClients.length === 0) { - server.reply({ - cmd: 'warn', - text: 'Could not find user(s) in channel' - }, socket); - - return; - } - - let newChannel = ''; - let kicked = []; - for (let i = 0, j = badClients.length; i < j; i++) { - if (badClients[i].uType !== 'user') { - server.reply({ - cmd: 'warn', - text: 'Cannot kick other mods, how rude' - }, socket); - } else { - newChannel = Math.random().toString(36).substr(2, 8); - badClients[i].channel = newChannel; - - // inform mods with where they were sent - server.broadcast({ - cmd: 'info', - text: `${badClients[i].nick} was banished to ?${newChannel}` - }, { channel: socket.channel, uType: 'mod' }); - - kicked.push(badClients[i].nick); - console.log(`${socket.nick} [${socket.trip}] kicked ${badClients[i].nick} in ${socket.channel}`); - } - } - - if (kicked.length === 0) { - return; - } - - // broadcast client leave event - for (let i = 0, j = kicked.length; i < j; i++) { - server.broadcast({ - cmd: 'onlineRemove', - nick: kicked[i] - }, { channel: socket.channel }); - } - - // publicly broadcast kick event - server.broadcast({ - cmd: 'info', - text: `Kicked ${kicked.join(', ')}` - }, { channel: socket.channel, uType: 'user' }); - - core.managers.stats.increment('users-kicked', kicked.length); -}; - -exports.requiredData = ['nick']; - -exports.info = { - name: 'kick', - usage: 'kick {nick}', - description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' -};
\ No newline at end of file |