aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/admin
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-03-14 06:26:53 +0100
committermarzavec <admin@marzavec.com>2018-03-14 06:26:53 +0100
commit39ec02d3c4cb5f5980b172d30404210de2479f0f (patch)
treeb837c9cfff94c62aa3de9880e4f7d07460734984 /server/src/commands/admin
parentstabilized modules and server cmd field (diff)
downloadhackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.tar.gz
hackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.zip
Streamlined modules, server tweaks, better feedback
Diffstat (limited to '')
-rw-r--r--server/src/commands/admin/addmod.js14
-rw-r--r--server/src/commands/admin/listusers.js2
-rw-r--r--server/src/commands/admin/reload.js6
-rw-r--r--server/src/commands/admin/saveconfig.js2
-rw-r--r--server/src/commands/admin/shout.js2
5 files changed, 15 insertions, 11 deletions
diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js
index dba5aba..e9dde2c 100644
--- a/server/src/commands/admin/addmod.js
+++ b/server/src/commands/admin/addmod.js
@@ -1,5 +1,5 @@
/*
-
+ Description: Adds the target trip to the mod list then elevates the uType
*/
'use strict';
@@ -16,14 +16,16 @@ exports.run = async (core, server, socket, data) => {
core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save
- for (let client of server.clients) {
- if (typeof client.trip !== 'undefined' && client.trip === data.trip) {
- client.uType = 'mod';
+ let newMod = server.findSockets({ trip: data.trip });
+
+ if (newMod.length !== 0) {
+ for (let i = 0, l = newMod.length; i < l; i++) {
+ newMod[i].uType = 'mod';
- server.reply({
+ server.send({
cmd: 'info',
text: 'You are now a mod.'
- }, client);
+ }, newMod[i]);
}
}
diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js
index 1ddb16b..226b000 100644
--- a/server/src/commands/admin/listusers.js
+++ b/server/src/commands/admin/listusers.js
@@ -1,5 +1,5 @@
/*
-
+ Description: Outputs all current channels and their user nicks
*/
'use strict';
diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js
index 88e40c7..387ae97 100644
--- a/server/src/commands/admin/reload.js
+++ b/server/src/commands/admin/reload.js
@@ -1,5 +1,5 @@
/*
-
+ Description: Clears and resets the command modules, outputting any errors
*/
'use strict';
@@ -14,7 +14,9 @@ exports.run = async (core, server, socket, data) => {
loadResult += core.commands.loadCommands();
if (loadResult == '') {
- loadResult = 'Commands reloaded without errors!';
+ loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`;
+ } else {
+ loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`;
}
server.reply({
diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js
index 4c6dff8..0c4e0c9 100644
--- a/server/src/commands/admin/saveconfig.js
+++ b/server/src/commands/admin/saveconfig.js
@@ -1,5 +1,5 @@
/*
-
+ Description: Writes any changes to the config to the disk
*/
'use strict';
diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js
index c3cfded..736134a 100644
--- a/server/src/commands/admin/shout.js
+++ b/server/src/commands/admin/shout.js
@@ -1,5 +1,5 @@
/*
-
+ Description: Emmits a server-wide message as `info`
*/
'use strict';