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