mirror of
https://github.com/gizmo4487/O-Bot.git
synced 2026-07-14 08:35:55 -05:00
Formatting changes + Update version to 1.0.0
This commit is contained in:
@@ -1,33 +1,35 @@
|
||||
const { createAudioResource, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice');
|
||||
const {
|
||||
createAudioResource,
|
||||
createAudioPlayer,
|
||||
NoSubscriberBehavior,
|
||||
} = require("@discordjs/voice");
|
||||
class RadioPlayer {
|
||||
static audioPlayer = null;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
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,
|
||||
});
|
||||
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;
|
||||
module.exports = RadioPlayer;
|
||||
|
||||
Reference in New Issue
Block a user