eximiabots-radiox/src/client/events/SIGINT.js

52 lines
2.0 KiB
JavaScript
Raw Normal View History

2021-09-02 13:50:01 +00:00
import Discord from "discord.js";
module.exports = {
name: 'SIGINT',
async execute(client) {
2021-09-02 14:37:07 +00:00
setTimeout(async function () {
client.user.setStatus('idle');
2021-09-02 13:50:01 +00:00
let message = {};
if (!client.stations) return process.exit();
let currentRadios = client.radio.keys();
let radio = currentRadios.next();
let stoppedRadios = "";
client.user.setStatus('idle');
while (!radio.done) {
2021-09-02 14:37:07 +00:00
let currentRadio = await client.radio.get(radio.value);
currentRadio.guild = await client.datastore.getEntry(radio.value).guild;
2021-09-02 13:50:01 +00:00
if (currentRadio) {
2021-09-02 14:37:07 +00:00
await client.funcs.statisticsUpdate(client, currentRadio.guild, currentRadio);
2021-09-02 13:50:01 +00:00
currentRadio.connection?.destroy();
currentRadio.audioPlayer?.stop();
currentRadio.message?.delete();
const cembed = 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(client.messages.sendedMaintenanceMessage)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
currentRadio.textChannel.send({ embeds: [cembed] });
client.radio.delete(radio.value);
}
2021-09-02 14:37:07 +00:00
radio = await currentRadios.next();
2021-09-02 13:50:01 +00:00
}
2021-09-02 14:37:07 +00:00
2021-09-02 13:50:01 +00:00
console.log("\n");
client.funcs.logger("Bot", "Closing");
2021-09-02 14:37:07 +00:00
console.log("\n");
client.user.setStatus('dnd');
2021-09-02 13:50:01 +00:00
2021-09-02 14:37:07 +00:00
setTimeout(function () {
process.exit();
}, 5000);
}, 5000);
2021-09-02 13:50:01 +00:00
}
}