mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 01:53:17 +00:00
Added SIGINT event
This commit is contained in:
parent
12337f499b
commit
706e65bc06
@ -37,6 +37,13 @@ class RadioClient extends Client {
|
|||||||
this.funcs.msToTime = require("./client/funcs/msToTime.js");
|
this.funcs.msToTime = require("./client/funcs/msToTime.js");
|
||||||
this.funcs.statisticsUpdate = require("./client/funcs/statisticsUpdate.js");
|
this.funcs.statisticsUpdate = require("./client/funcs/statisticsUpdate.js");
|
||||||
|
|
||||||
|
console.log('RadioX ' + this.config.version);
|
||||||
|
console.log('Internet Radio to your Discord guild');
|
||||||
|
console.log('(c)2020-2021 EximiaBots by Warén Group');
|
||||||
|
console.log('');
|
||||||
|
|
||||||
|
this.funcs.logger("Bot", "Starting");
|
||||||
|
|
||||||
const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".js"));
|
const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".js"));
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const command = require(`./client/commands/${file}`);
|
const command = require(`./client/commands/${file}`);
|
||||||
@ -64,6 +71,10 @@ class RadioClient extends Client {
|
|||||||
require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
|
require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
require(`${events}SIGINT`).execute(this);
|
||||||
|
});
|
||||||
|
|
||||||
this.on("error", error => {
|
this.on("error", error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
46
src/client/events/SIGINT.js
Normal file
46
src/client/events/SIGINT.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import Discord from "discord.js";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'SIGINT',
|
||||||
|
async execute(client) {
|
||||||
|
/*setTimeout(function () {
|
||||||
|
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) {
|
||||||
|
|
||||||
|
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();
|
||||||
|
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);
|
||||||
|
stoppedRadios += "-" + radio.value + ": " + currentRadio.guild.name + "\n";
|
||||||
|
}
|
||||||
|
radio = currentRadios.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("\n");
|
||||||
|
client.funcs.logger("Bot", "Closing");
|
||||||
|
console.log("\n");*/
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
/*}, 5000);*/
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user