From c719020e17cb1c98da55be6cc7efe0e50ab51ffa Mon Sep 17 00:00:00 2001 From: marzavec Date: Sat, 29 Sep 2018 23:44:36 -0700 Subject: Added hooks, modules and cleaned up code --- server/src/commands/admin/addmod.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'server/src/commands/admin/addmod.js') 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: '' }` }; -- cgit v1.2.1