package de.yannicpunktdee.yoshibot.audio;

import com.sedmelluq.discord.lavaplayer.player.event.AudioEvent;
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener;

import de.yannicpunktdee.yoshibot.main.YoshiBot;
import lombok.Getter;
import net.dv8tion.jda.api.managers.AudioManager;

public class AudioPlayerListener implements AudioEventListener {
	
	private final AudioManager audioManager;

	@Getter
	private static boolean isPlayingTrack = false;
	
	
	public AudioPlayerListener(AudioManager audioManager) {
		this.audioManager = audioManager;
	}

	@Override
	public void onEvent(AudioEvent event) {
		if(event.player.getPlayingTrack() == null) {
			event.player.stopTrack();
			isPlayingTrack = false;
			YoshiBot.getInstance().joinVoiceChannelWithMostMembers();
		} else isPlayingTrack = true;
	}

}
