Complete rewrite - Added slash commands

This commit is contained in:
2025-05-04 18:55:40 -05:00
parent 382ac41d7f
commit 6cae1d1eea
13 changed files with 3478 additions and 711 deletions

33
cmd/util/RadioPlayer.js Normal file
View File

@@ -0,0 +1,33 @@
const { createAudioResource, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice');
class RadioPlayer {
static audioPlayer = null;
static async getAudioPlayer(url) {
if(this.audioPlayer == null) {
let data = await fetch(url, {
headers: {
'User-Agent': 'O-Bot'
}}
);
if(data.status == 200) {
console.log('Creating audio resource');
var fileStream = data.body;
var res = createAudioResource(fileStream, {inlineVolume: true});
//res.volume.setVolume(2);
this.audioPlayer = createAudioPlayer({
behaviors: {noSubscriber: NoSubscriberBehavior.Play},
});
this.audioPlayer.play(res);
return this.audioPlayer;
}
else {
throw Error('Radio is down!');
}
}
else {
return this.audioPlayer;
}
}
}
module.exports = RadioPlayer;