aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/admin/reload.js
blob: e2cfbe608111c83ce9e7c5f23439fbb1dd4a1ff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
  Description: Clears and resets the command modules, outputting any errors
*/

exports.run = async (core, server, socket, data) => {
  if (socket.uType != 'admin') {
    // ignore if not admin
    return;
  }

  let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands');
  loadResult += core.commands.loadCommands();

  if (loadResult == '') {
    loadResult = `Loaded ${core.commands._commands.length} commands, 0 errors`;
  } else {
    loadResult = `Loaded ${core.commands._commands.length} commands, error(s): ${loadResult}`;
  }

  server.reply({
    cmd: 'info',
    text: loadResult
  }, socket);

  server.broadcast({
    cmd: 'info',
    text: loadResult
  }, { uType: 'mod' });
};

exports.info = {
  name: 'reload',
  description: '(Re)loads any new commands into memory, outputs errors if any'
};