2018-09-30 14:44:36 +08:00
|
|
|
/*
|
|
|
|
Description: Removes target trip from the config as a mod and downgrades the socket type
|
|
|
|
*/
|
|
|
|
|
2020-03-06 00:49:25 +08:00
|
|
|
import * as UAC from "../utility/UAC/info";
|
|
|
|
|
2018-09-30 14:44:36 +08:00
|
|
|
// module main
|
2019-11-07 15:35:23 +08:00
|
|
|
export async function run(core, server, socket, data) {
|
2018-09-30 14:44:36 +08:00
|
|
|
// increase rate limit chance and ignore if not admin
|
2020-03-06 00:49:25 +08:00
|
|
|
if (!UAC.isAdmin(socket.level)) {
|
2019-11-07 15:35:23 +08:00
|
|
|
return server.police.frisk(socket.address, 20);
|
2018-09-30 14:44:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// remove trip from config
|
2019-11-07 15:35:23 +08:00
|
|
|
core.config.mods = core.config.mods.filter((mod) => mod.trip !== data.trip);
|
2018-09-30 14:44:36 +08:00
|
|
|
|
|
|
|
// find targets current connections
|
2019-11-07 15:35:23 +08:00
|
|
|
const targetMod = server.findSockets({ trip: data.trip });
|
2019-02-03 05:34:06 +08:00
|
|
|
if (targetMod.length !== 0) {
|
2019-11-07 15:35:23 +08:00
|
|
|
for (let i = 0, l = targetMod.length; i < l; i += 1) {
|
2018-09-30 14:44:36 +08:00
|
|
|
// downgrade privilages
|
|
|
|
targetMod[i].uType = 'user';
|
2020-03-06 00:49:25 +08:00
|
|
|
targetMod[i].level = UAC.levels.user;
|
2018-09-30 14:44:36 +08:00
|
|
|
|
|
|
|
// inform ex-mod
|
|
|
|
server.send({
|
|
|
|
cmd: 'info',
|
2019-11-07 15:35:23 +08:00
|
|
|
text: 'You are now a user.',
|
2018-09-30 14:44:36 +08:00
|
|
|
}, targetMod[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// return success message
|
|
|
|
server.reply({
|
|
|
|
cmd: 'info',
|
2019-02-03 05:34:06 +08:00
|
|
|
text: `Removed mod trip: ${
|
|
|
|
data.trip
|
2019-11-07 15:35:23 +08:00
|
|
|
}, remember to run 'saveconfig' to make it permanent`,
|
2018-09-30 14:44:36 +08:00
|
|
|
}, socket);
|
|
|
|
|
|
|
|
// notify all mods
|
|
|
|
server.broadcast({
|
|
|
|
cmd: 'info',
|
2019-11-07 15:35:23 +08:00
|
|
|
text: `Removed mod: ${data.trip}`,
|
2020-03-06 00:49:25 +08:00
|
|
|
}, { level: UAC.isModerator });
|
2018-09-30 14:44:36 +08:00
|
|
|
|
2019-11-07 15:35:23 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const requiredData = ['trip'];
|
|
|
|
export const info = {
|
2018-09-30 14:44:36 +08:00
|
|
|
name: 'removemod',
|
|
|
|
description: 'Removes target trip from the config as a mod and downgrades the socket type',
|
|
|
|
usage: `
|
2019-11-07 15:35:23 +08:00
|
|
|
API: { cmd: 'removemod', trip: '<target trip>' }`,
|
2018-09-30 14:44:36 +08:00
|
|
|
};
|