aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/admin/saveconfig.js
blob: 0c4e0c9b9359eedcb1ac3c98e44db14c33f958bf (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
36
37
38
/*
  Description: Writes any changes to the config to the disk
*/

'use strict';

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

  let saveResult = core.managers.config.save();

  if (!saveResult) {
    server.reply({
      cmd: 'warn',
      text: 'Failed to save config, check logs.'
    }, client);

    return;
  }

  server.reply({
    cmd: 'info',
    text: 'Config saved!'
  }, socket);

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

exports.info = {
  name: 'saveconfig',
  description: 'Saves current config'
};