aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod/kick.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/mod/kick.js')
-rw-r--r--server/src/commands/mod/kick.js37
1 files changed, 19 insertions, 18 deletions
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js
index f3bc7ca..cb01d5c 100644
--- a/server/src/commands/mod/kick.js
+++ b/server/src/commands/mod/kick.js
@@ -3,37 +3,37 @@
*/
// module main
-exports.run = async (core, server, socket, data) => {
+export async function run(core, server, socket, data) {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server.police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.address, 10);
}
// check user input
if (typeof data.nick !== 'string') {
if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) {
- return;
+ return true;
}
}
// find target user(s)
- let badClients = server.findSockets({ channel: socket.channel, nick: data.nick });
+ const badClients = server.findSockets({ channel: socket.channel, nick: data.nick });
if (badClients.length === 0) {
return server.reply({
cmd: 'warn',
- text: 'Could not find user(s) in channel'
+ text: 'Could not find user(s) in channel',
}, socket);
}
// check if found targets are kickable, commit kick
let newChannel = '';
- let kicked = [];
- for (let i = 0, j = badClients.length; i < j; i++) {
+ const kicked = [];
+ for (let i = 0, j = badClients.length; i < j; i += 1) {
if (badClients[i].uType !== 'user') {
server.reply({
cmd: 'warn',
- text: 'Cannot kick other mods, how rude'
+ text: 'Cannot kick other mods, how rude',
}, socket);
} else {
newChannel = Math.random().toString(36).substr(2, 8);
@@ -42,7 +42,7 @@ exports.run = async (core, server, socket, data) => {
// inform mods with where they were sent
server.broadcast({
cmd: 'info',
- text: `${badClients[i].nick} was banished to ?${newChannel}`
+ text: `${badClients[i].nick} was banished to ?${newChannel}`,
}, { channel: socket.channel, uType: 'mod' });
kicked.push(badClients[i].nick);
@@ -51,32 +51,33 @@ exports.run = async (core, server, socket, data) => {
}
if (kicked.length === 0) {
- return;
+ return true;
}
// broadcast client leave event
- for (let i = 0, j = kicked.length; i < j; i++) {
+ for (let i = 0, j = kicked.length; i < j; i += 1) {
server.broadcast({
cmd: 'onlineRemove',
- nick: kicked[i]
+ nick: kicked[i],
}, { channel: socket.channel });
}
// publicly broadcast kick event
server.broadcast({
cmd: 'info',
- text: `Kicked ${kicked.join(', ')}`
+ text: `Kicked ${kicked.join(', ')}`,
}, { channel: socket.channel, uType: 'user' });
// stats are fun
core.stats.increment('users-kicked', kicked.length);
-};
-// module meta
-exports.requiredData = ['nick'];
-exports.info = {
+ return true;
+}
+
+export const requiredData = ['nick'];
+export const info = {
name: 'kick',
description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings',
usage: `
- API: { cmd: 'kick', nick: '<target nick>' }`
+ API: { cmd: 'kick', nick: '<target nick>' }`,
};