aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod/ban.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/mod/ban.js')
-rw-r--r--server/src/commands/mod/ban.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index 9c8eb4f..dd5f01e 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -3,53 +3,53 @@
*/
// 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') {
- return;
+ return true;
}
// find target user
- let targetNick = data.nick;
+ const targetNick = data.nick;
let badClient = server.findSockets({ channel: socket.channel, nick: targetNick });
if (badClient.length === 0) {
return server.reply({
cmd: 'warn',
- text: 'Could not find user in channel'
+ text: 'Could not find user in channel',
}, socket);
}
- badClient = badClient[0];
+ [badClient] = badClient;
// i guess banning mods or admins isn't the best idea?
if (badClient.uType !== 'user') {
return server.reply({
cmd: 'warn',
- text: 'Cannot ban other mods, how rude'
+ text: 'Cannot ban other mods, how rude',
}, socket);
}
// commit arrest record
- server.police.arrest(badClient.remoteAddress, badClient.hash);
+ server.police.arrest(badClient.address, badClient.hash);
console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`);
// notify normal users
server.broadcast({
cmd: 'info',
- text: `Banned ${targetNick}`
+ text: `Banned ${targetNick}`,
}, { channel: socket.channel, uType: 'user' });
// notify mods
server.broadcast({
cmd: 'info',
- text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`
+ text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`,
}, { uType: 'mod' });
// force connection closed
@@ -57,13 +57,14 @@ exports.run = async (core, server, socket, data) => {
// stats are fun
core.stats.increment('users-banned');
-};
-// module meta
-exports.requiredData = ['nick'];
-exports.info = {
+ return true;
+}
+
+export const requiredData = ['nick'];
+export const info = {
name: 'ban',
description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter',
usage: `
- API: { cmd: 'ban', nick: '<target nickname>' }`
+ API: { cmd: 'ban', nick: '<target nickname>' }`,
};