From 1e24e895682dade6688efcf4276f1c821b7da49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 5 Sep 2021 02:12:57 +0300 Subject: [PATCH] Updated maintenance command --- src/client/commands/maintenance.js | 78 +++++++++++++++++------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.js index 08a52fc..21cb4fa 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.js @@ -10,43 +10,53 @@ module.exports = { if(!client.funcs.isDev(client.config.devId, interaction.user.id)) return interaction.reply(client.messageEmojis["error"] + client.messages.notAllowed); - if(!client.stations) { - message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); - return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist); - } - - let currentRadios = client.radio.keys(); - let radio = currentRadios.next(); - let stoppedRadios = ""; + if(client.config.version.includes("-dev")){ + interaction.reply({ + content: "Maintenance Initiated", + ephemeral: true + }); - client.user.setStatus('dnd'); - - while (!radio.done) { - let currentRadio = client.radio.get(radio.value); - currentRadio.guild = client.datastore.getEntry(radio.value).guild; - - if(currentRadio){ - client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio); - currentRadio.connection?.destroy(); - currentRadio.audioPlayer?.stop(); - currentRadio.message?.delete(); - client.radio.delete(radio.value); - stoppedRadios += "-" + radio.value + ": " + currentRadio.guild.name + "\n"; + process.emit('SIGINT'); + } else { + if(!client.stations) { + message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild); + return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist); } - radio = currentRadios.next(); + + let currentRadios = client.radio.keys(); + let radio = currentRadios.next(); + let stoppedRadios = ""; + + client.user.setStatus('dnd'); + + while (!radio.done) { + let currentRadio = client.radio.get(radio.value); + currentRadio.guild = client.datastore.getEntry(radio.value).guild; + + if(currentRadio){ + client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio); + currentRadio.connection?.destroy(); + currentRadio.audioPlayer?.stop(); + currentRadio.message?.delete(); + client.radio.delete(radio.value); + stoppedRadios += "-" + radio.value + ": " + currentRadio.guild.name + "\n"; + } + radio = currentRadios.next(); + } + + const embed = new Discord.MessageEmbed() + .setTitle(client.messages.maintenanceTitle) + .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["maintenance"].replace(/[^0-9]+/g, '')) + .setColor(client.config.embedColor) + .setDescription("Stopped all radios" + "\n" + stoppedRadios) + .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') + .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); + + interaction.reply({ + embeds: [embed], + ephemeral: true + }); } - const embed = new Discord.MessageEmbed() - .setTitle(client.messages.maintenanceTitle) - .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["maintenance"].replace(/[^0-9]+/g, '')) - .setColor(client.config.embedColor) - .setDescription("Stopped all radios" + "\n" + stoppedRadios) - .setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png') - .setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')); - - interaction.reply({ - embeds: [embed], - ephemeral: true - }); } }; \ No newline at end of file