From f28e65ab8035682372edbe1c11d9ca2581e0a2e6 Mon Sep 17 00:00:00 2001 From: marzavec Date: Wed, 6 Nov 2019 23:35:23 -0800 Subject: Syntax update and formatting tweaks --- server/src/commands/mod/ban.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'server/src/commands/mod/ban.js') 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: '' }` + API: { cmd: 'ban', nick: '' }`, }; -- cgit v1.2.1