mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-14 04:30:18 +00:00
Update play function
This commit is contained in:
parent
73d330d1e2
commit
9517ba1fa9
@ -3,35 +3,12 @@ const {
|
|||||||
createAudioResource
|
createAudioResource
|
||||||
} = require("@discordjs/voice");
|
} = require("@discordjs/voice");
|
||||||
|
|
||||||
module.exports = async function play(interaction, guild, client, url) {
|
module.exports = async function play(client, interaction, guild, station) {
|
||||||
let message = {};
|
let message = {};
|
||||||
const radio = client.radio.get(guild.id);
|
const radio = client.radio.get(guild.id);
|
||||||
const resource = createAudioResource(url);
|
const audioPlayer = client.streamer.listen(station);
|
||||||
radio.connection.subscribe(radio.audioPlayer);
|
radio.connection.subscribe(audioPlayer);
|
||||||
radio.audioPlayer.play(resource);
|
client.funcs.logger('Radio', guild.id + " / " + "Play" + " / " + radio.station.name);
|
||||||
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
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", 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);
|
message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner);
|
||||||
|
Loading…
Reference in New Issue
Block a user