diff options
author | marzavec <admin@marzavec.com> | 2018-09-30 08:44:36 +0200 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2018-09-30 08:44:36 +0200 |
commit | c719020e17cb1c98da55be6cc7efe0e50ab51ffa (patch) | |
tree | 4c1e7f05aec2b6a995e21d2bbecbb45c2ae14bd6 /server/src/commands/admin/addmod.js | |
parent | Merge pull request #28 from henrywright/27 (diff) | |
download | hackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.tar.gz hackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.zip |
Added hooks, modules and cleaned up code
Diffstat (limited to 'server/src/commands/admin/addmod.js')
-rw-r--r-- | server/src/commands/admin/addmod.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index bde54a1..c4fcdd5 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -2,23 +2,24 @@ Description: Adds the target trip to the mod list then elevates the uType */ +// module main exports.run = async (core, server, socket, data) => { // increase rate limit chance and ignore if not admin if (socket.uType != 'admin') { - server._police.frisk(socket.remoteAddress, 20); - - return; + return server._police.frisk(socket.remoteAddress, 20); } // add new trip to config core.config.mods.push({ trip: data.trip }); // purposely not using `config.set()` to avoid auto-save - // upgarde existing connections & notify user + // find targets current connections let newMod = server.findSockets({ trip: data.trip }); if (newMod.length !== 0) { for (let i = 0, l = newMod.length; i < l; i++) { + // upgrade privilages newMod[i].uType = 'mod'; + // inform new mod server.send({ cmd: 'info', text: 'You are now a mod.' @@ -29,20 +30,21 @@ exports.run = async (core, server, socket, data) => { // return success message server.reply({ cmd: 'info', - text: `Added mod trip: ${data.trip}` + text: `Added mod trip: ${data.trip}, remember to run 'saveconfig' to make it permanent` }, socket); // notify all mods server.broadcast({ cmd: 'info', - text: `Added mod trip: ${data.trip}` + text: `Added mod: ${data.trip}` }, { uType: 'mod' }); }; +// module meta exports.requiredData = ['trip']; - exports.info = { name: 'addmod', - usage: 'addmod {trip}', - description: 'Adds target trip to the config as a mod and upgrades the socket type' + description: 'Adds target trip to the config as a mod and upgrades the socket type', + usage: ` + API: { cmd: 'addmod', trip: '<target trip>' }` }; |