2020-03-09 11:17:47 +00:00
|
|
|
module.exports = async function (guild, client, url) {
|
2020-03-02 19:38:42 +00:00
|
|
|
|
|
|
|
const radio = client.radio.get(guild.id);
|
2020-03-08 23:26:24 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
const dispatcher = radio.connection
|
|
|
|
.play(url, { bitrate: 1024, passes: 10, volume: 1, highWaterMark: 1 << 25 })
|
2020-03-02 20:54:01 +00:00
|
|
|
.on("finish", () => {
|
2020-03-08 09:41:25 +00:00
|
|
|
radio.voiceChannel.leave();
|
2020-03-08 14:54:57 +00:00
|
|
|
client.radio.delete(guild.id);
|
2020-03-08 09:41:25 +00:00
|
|
|
return;
|
2020-03-02 19:38:42 +00:00
|
|
|
});
|
2020-03-08 23:26:24 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
dispatcher.on('start', () => {
|
|
|
|
dispatcher.player.streamingData.pausedTime = 0;
|
|
|
|
});
|
2020-03-08 23:31:24 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
dispatcher.on('error', error => {
|
|
|
|
console.error(error);
|
|
|
|
radio.voiceChannel.leave();
|
|
|
|
client.radio.delete(guild.id);
|
|
|
|
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
|
|
|
});
|
2020-03-08 23:31:24 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
dispatcher.setVolume(radio.volume / 10);
|
2020-03-08 23:31:24 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
radio.textChannel.send('Start playing');
|
|
|
|
radio.playing = true;
|
2020-03-08 23:26:24 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
}
|