Update maintenance command

This commit is contained in:
Christer Warén 2021-09-12 17:49:21 +03:00
parent a20e7a1c8e
commit 4b0efe7491

View File

@ -1,4 +1,5 @@
import Discord from "discord.js"; import Discord from "discord.js";
import Streamer from "../classes/Streamer.js";
const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const _importDynamic = new Function('modulePath', 'return import(modulePath)');
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
@ -103,32 +104,33 @@ module.exports = {
ephemeral: true ephemeral: true
}); });
let guilds = await client.guilds.fetch();
switch(action){ switch(action){
case "0": case "0":
client.config.maintenance = true; client.config.maintenanceMode = true;
process.emit('SIGINT'); process.emit('SIGINT');
break; break;
case "4": case "4":
client.config.maintenance = true; client.config.maintenanceMode = true;
client.user.setStatus('idle'); client.user.setStatus('idle');
client.funcs.saveRadios(client); client.funcs.saveRadios(client);
client.user.setStatus('online'); client.user.setStatus('online');
client.config.maintenance = false; client.config.maintenanceMode = false;
break; break;
case "5": case "5":
client.config.maintenance = true; client.config.maintenanceMode = true;
client.user.setStatus('idle'); client.user.setStatus('idle');
let guilds = await client.guilds.fetch();
client.funcs.restoreRadios(client, guilds); client.funcs.restoreRadios(client, guilds);
client.user.setStatus('online'); client.user.setStatus('online');
client.config.maintenance = false; client.config.maintenanceMode = false;
break; break;
case "6": case "6":
client.config.maintenance = true; client.config.maintenanceMode = true;
client.user.setStatus('idle'); client.user.setStatus('idle');
require(`../commands.js`).execute(client); require(`../commands.js`).execute(client);
client.user.setStatus('online'); client.user.setStatus('online');
client.config.maintenance = false; client.config.maintenanceMode = false;
break; break;
case "7": case "7":
try { try {
@ -148,41 +150,43 @@ module.exports = {
case "8": case "8":
client.user.setStatus('dnd'); client.user.setStatus('dnd');
client.funcs.logger("Maintenance Mode", "Enabled"); client.funcs.logger("Maintenance Mode", "Enabled");
client.config.maintenance = true; client.config.maintenanceMode = true;
break; break;
case "9": case "9":
client.user.setStatus('online'); client.user.setStatus('online');
client.funcs.logger("Maintenance Mode", "Disabled"); client.funcs.logger("Maintenance Mode", "Disabled");
client.config.maintenance = false; client.config.maintenanceMode = false;
break; break;
case "10": case "10":
client.config.maintenance = true; client.config.maintenanceMode = true;
client.user.setStatus('idle'); client.user.setStatus('idle');
client.funcs.saveRadios(client); client.funcs.saveRadios(client);
client.config.streamerMode = "manual"; client.config.streamerMode = "manual";
client.streamer.leave(client); client.streamer.leave(client);
client.streamer = new Streamer();
client.streamer.init(client); client.streamer.init(client);
let guilds = await client.guilds.fetch();
client.funcs.restoreRadios(client, guilds); client.funcs.restoreRadios(client, guilds);
client.user.setStatus('online'); client.user.setStatus('online');
client.config.maintenance = false; client.config.maintenanceMode = false;
break; break;
case "11": case "11":
client.config.maintenance = true; client.config.maintenanceMode = true;
client.user.setStatus('idle'); client.user.setStatus('idle');
client.funcs.saveRadios(client); client.funcs.saveRadios(client);
client.config.streamerMode = "auto"; client.config.streamerMode = "auto";
client.streamer.leave(client); client.streamer.leave(client);
client.streamer = new Streamer();
client.streamer.init(client); client.streamer.init(client);
let guilds = await client.guilds.fetch();
client.funcs.restoreRadios(client, guilds); client.funcs.restoreRadios(client, guilds);
client.user.setStatus('online'); client.user.setStatus('online');
client.config.maintenance = false; client.config.maintenanceMode = false;
break; break;
default: default: