package fr.Skydust.JdrBot.audio.handler;

import fr.Skydust.JdrBot.stock.RecordState;
import net.dv8tion.jda.api.audio.AudioReceiveHandler;
import net.dv8tion.jda.api.audio.CombinedAudio;
import net.dv8tion.jda.api.audio.UserAudio;
import org.jetbrains.annotations.NotNull;

public class JdrBotARH implements AudioReceiveHandler {
	private final RecordState recordState;

	public JdrBotARH(RecordState rs) {
		this.recordState = rs;
	}

	@Override
	public boolean canReceiveCombined() {
		return true;
	}

    @Override
	public void handleCombinedAudio(@NotNull CombinedAudio combinedAudio) {
		if(recordState.isRecording) {
			recordState.addBytes(combinedAudio.getAudioData(1.0));
		}
	}
}
