mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-09 23:00:18 +00:00
Updated code
This commit is contained in:
parent
606dcc0ab3
commit
2fec81e84d
@ -18,7 +18,7 @@ module.exports = {
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
console.log('[Slash Commands] Started refreshing application (/) commands.');
|
||||
|
||||
if(version.includes("-dev")){
|
||||
await rest.put(
|
||||
@ -44,8 +44,9 @@ module.exports = {
|
||||
);
|
||||
}
|
||||
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
console.log('[Slash Commands] Successfully reloaded application (/) commands.' + "\n");
|
||||
} catch (error) {
|
||||
console.log('[Slash Commands] Reloading application (/) commands failed.' + "\n");
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
|
@ -88,7 +88,7 @@ module.exports = {
|
||||
|
||||
radio.station = station;
|
||||
radio.textChannel = interaction.channel;
|
||||
play(interaction.guild, client, url);
|
||||
play(interaction, interaction.guild, client, url);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -131,6 +131,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function play(interaction, guild, client, url) {
|
||||
let message = {};
|
||||
const radio = client.radio.get(guild.id);
|
||||
@ -139,18 +140,21 @@ function play(interaction, guild, client, url) {
|
||||
radio.audioPlayer.play(resource);
|
||||
resource.playStream
|
||||
.on("readable", () => {
|
||||
console.log("Stream started");
|
||||
console.log("[Radio] Stream started" + " / " + guild.id + " / " + radio.station.name);
|
||||
})
|
||||
.on("finish", () => {
|
||||
console.log("Stream finished");
|
||||
console.log("[Radio] Stream finished" + " / " + guild.id);
|
||||
client.funcs.statisticsUpdate(client, guild, radio);
|
||||
radio.connection.destroy();
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
client.radio.delete(guild.id);
|
||||
return;
|
||||
})
|
||||
.on("error", error => {
|
||||
console.log("[Radio] Stream errored");
|
||||
console.error(error);
|
||||
radio.connection.destroy();
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
client.radio.delete(guild.id);
|
||||
return interaction.reply(client.messages.errorPlaying);
|
||||
});
|
||||
|
@ -7,6 +7,7 @@ module.exports = {
|
||||
console.log('RadioX ' + client.config.version);
|
||||
console.log('Internet Radio to your Discord guild');
|
||||
console.log('(c)2020-2021 EximiaBots by Warén Group');
|
||||
console.log('');
|
||||
|
||||
client.developers = "";
|
||||
let user = "";
|
||||
@ -24,7 +25,7 @@ module.exports = {
|
||||
.then(client.funcs.checkFetchStatus)
|
||||
.then(response => response.json());
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
//console.error(error);
|
||||
}
|
||||
|
||||
setInterval(async () => {
|
||||
@ -33,7 +34,7 @@ module.exports = {
|
||||
.then(client.funcs.checkFetchStatus)
|
||||
.then(response => response.json());
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
//console.error(error);
|
||||
}
|
||||
}, 3600000);
|
||||
|
||||
|
@ -16,8 +16,9 @@ module.exports = {
|
||||
|
||||
if (newState.channel === null) {
|
||||
client.funcs.statisticsUpdate(client, newState.guild, radio);
|
||||
radio.connection = null;
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
console.log("[Radio] Stream stopped" + " / " + newState.guild.id);
|
||||
return client.radio.delete(newState.guild.id);
|
||||
}
|
||||
|
||||
@ -39,6 +40,7 @@ module.exports = {
|
||||
client.funcs.statisticsUpdate(client, newState.guild, radio);
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
console.log("[Radio] Stream stopped" + " / " + newState.guild.id);
|
||||
client.radio.delete(oldState.guild.id);
|
||||
}
|
||||
return;
|
||||
@ -57,9 +59,10 @@ module.exports = {
|
||||
client.funcs.statisticsUpdate(client, newState.guild, radio);
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
console.log("[Radio] Stream stopped" + " / " + newState.guild.id);
|
||||
client.radio.delete(newState.guild.id);
|
||||
}
|
||||
}, 120000);
|
||||
}, 60000);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user