aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod/ban.js
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-09-30 08:44:36 +0200
committermarzavec <admin@marzavec.com>2018-09-30 08:44:36 +0200
commitc719020e17cb1c98da55be6cc7efe0e50ab51ffa (patch)
tree4c1e7f05aec2b6a995e21d2bbecbb45c2ae14bd6 /server/src/commands/mod/ban.js
parentMerge pull request #28 from henrywright/27 (diff)
downloadhackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.tar.gz
hackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.zip
Added hooks, modules and cleaned up code
Diffstat (limited to 'server/src/commands/mod/ban.js')
-rw-r--r--server/src/commands/mod/ban.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index 721ad27..8236136 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -2,12 +2,11 @@
Description: Adds the target socket's ip to the ratelimiter
*/
+// module main
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
- if (socket.uType == 'user') {
- server._police.frisk(socket.remoteAddress, 10);
-
- return;
+ if (socket.uType === 'user') {
+ return server._police.frisk(socket.remoteAddress, 10);
}
// check user input
@@ -20,24 +19,20 @@ exports.run = async (core, server, socket, data) => {
let badClient = server.findSockets({ channel: socket.channel, nick: targetNick });
if (badClient.length === 0) {
- server.reply({
+ return server.reply({
cmd: 'warn',
text: 'Could not find user in channel'
}, socket);
-
- return;
}
badClient = badClient[0];
// i guess banning mods or admins isn't the best idea?
if (badClient.uType !== 'user') {
- server.reply({
+ return server.reply({
cmd: 'warn',
text: 'Cannot ban other mods, how rude'
}, socket);
-
- return;
}
// commit arrest record
@@ -64,10 +59,11 @@ exports.run = async (core, server, socket, data) => {
core.managers.stats.increment('users-banned');
};
+// module meta
exports.requiredData = ['nick'];
-
exports.info = {
name: 'ban',
- usage: 'ban {nick}',
- description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter'
+ description: 'Disconnects the target nickname in the same channel as calling socket & adds to ratelimiter',
+ usage: `
+ API: { cmd: 'ban', nick: '<target nickname>' }`
};