aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod/speak.js
blob: 422ad2cd05e65c7bc8e4fe3b09c1522e63286837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* 
 * Description: Pardon a dumb user to be able to speak again
 * Author: simple
 */


exports.run = async (core, server, socket, data) => {
  if (socket.uType == 'user') {
    // ignore if not mod or admin
    return;
  }

  if (typeof data.ip !== 'string' && typeof data.hash !== 'string') {
    server.reply({
      cmd: 'warn',
      text: "hash:'targethash' or ip:'1.2.3.4' is required"
    }, socket);

    return;
  }
  
  let target;

  if (typeof data.ip === 'string') {
    target = getSocketHash(data.ip);
  } else {
    target = data.hash;
  }
  
  delete core.muzzledHashes[target];
  
  server.broadcast({
    cmd: 'info',
    text: `${socket.nick} unmuzzled : ${target}`
  }, { uType: 'mod' });
  
}

exports.info = {
  name: 'speak',
  usage: 'speak {[ip || hash]}',
  description: 'Pardon a dumb user to be able to speak again'
};