aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/admin/addmod.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/admin/addmod.js')
-rw-r--r--server/src/commands/admin/addmod.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js
index 6853a42..26cec40 100644
--- a/server/src/commands/admin/addmod.js
+++ b/server/src/commands/admin/addmod.js
@@ -3,26 +3,26 @@
*/
// 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
- if (socket.uType != 'admin') {
- return server.police.frisk(socket.remoteAddress, 20);
+ if (socket.uType !== 'admin') {
+ return server.police.frisk(socket.address, 20);
}
// add new trip to config
core.config.mods.push({ trip: data.trip });
// find targets current connections
- let newMod = server.findSockets({ trip: data.trip });
+ const newMod = server.findSockets({ trip: data.trip });
if (newMod.length !== 0) {
- for (let i = 0, l = newMod.length; i < l; i++) {
+ for (let i = 0, l = newMod.length; i < l; i += 1) {
// upgrade privilages
newMod[i].uType = 'mod';
// inform new mod
server.send({
cmd: 'info',
- text: 'You are now a mod.'
+ text: 'You are now a mod.',
}, newMod[i]);
}
}
@@ -30,21 +30,22 @@ exports.run = async (core, server, socket, data) => {
// return success message
server.reply({
cmd: 'info',
- text: `Added mod trip: ${data.trip}, remember to run 'saveconfig' to make it permanent`
+ 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: ${data.trip}`
+ text: `Added mod: ${data.trip}`,
}, { uType: 'mod' });
-};
-// module meta
-exports.requiredData = ['trip'];
-exports.info = {
+ return true;
+}
+
+export const requiredData = ['trip'];
+export const info = {
name: 'addmod',
description: 'Adds target trip to the config as a mod and upgrades the socket type',
usage: `
- API: { cmd: 'addmod', trip: '<target trip>' }`
+ API: { cmd: 'addmod', trip: '<target trip>' }`,
};