mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 05:53:18 +00:00
Update play function
This commit is contained in:
parent
73d330d1e2
commit
9517ba1fa9
@ -3,35 +3,12 @@ const {
|
||||
createAudioResource
|
||||
} = require("@discordjs/voice");
|
||||
|
||||
module.exports = async function play(interaction, guild, client, url) {
|
||||
module.exports = async function play(client, interaction, guild, station) {
|
||||
let message = {};
|
||||
const radio = client.radio.get(guild.id);
|
||||
const resource = createAudioResource(url);
|
||||
radio.connection.subscribe(radio.audioPlayer);
|
||||
radio.audioPlayer.play(resource);
|
||||
resource.playStream
|
||||
.on("readable", () => {
|
||||
client.funcs.logger('Radio', 'Stream started' + " / " + guild.id + " / " + radio.station.name);
|
||||
})
|
||||
.on("finish", () => {
|
||||
client.funcs.logger('Radio', 'Stream finished' + " / " + guild.id);
|
||||
client.funcs.statisticsUpdate(client, guild, radio);
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
client.radio.delete(guild.id);
|
||||
return;
|
||||
})
|
||||
.on("error", error => {
|
||||
client.funcs.logger('Radio', 'Stream errored');
|
||||
console.error(error);
|
||||
radio.connection?.destroy();
|
||||
radio.audioPlayer?.stop();
|
||||
client.radio.delete(guild.id);
|
||||
return interaction.reply({
|
||||
content: client.messages.errorPlaying,
|
||||
ephemeral: true
|
||||
});
|
||||
});
|
||||
const audioPlayer = client.streamer.listen(station);
|
||||
radio.connection.subscribe(audioPlayer);
|
||||
client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name);
|
||||
|
||||
message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name);
|
||||
message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner);
|
||||
|
Loading…
Reference in New Issue
Block a user