Update Streamer class

This commit is contained in:
Christer Warén 2021-09-11 18:27:01 +03:00
parent a043cde46e
commit 095b6ad775

View File

@ -2,14 +2,12 @@ const {
createAudioPlayer,
createAudioResource
} = require("@discordjs/voice");
const {
logger
} = require("../funcs/logger.js");
module.exports = class {
constructor() {
this.map = new Map();
this.stations = null;
this.logger = require("../funcs/logger.js");
}
init(client){
@ -27,15 +25,15 @@ module.exports = class {
audioPlayer.play(resource);
resource.playStream
.on("readable", () => {
logger('Streamer', station.name + " / " + "Readable");
this.logger('Streamer', station.name + " / " + "Readable");
this.map.set(station.name, audioPlayer);
})
.on("finish", () => {
logger('Streamer', station.name + " / " + "Finished");
this.logger('Streamer', station.name + " / " + "Finished");
this.map.delete(station.name);
})
.on("error", error => {
logger('Streamer', station.name + " / " + "Error");
this.logger('Streamer', station.name + " / " + "Error");
this.map.delete(station.name);
});
return audioPlayer;