use crate::voice::connection::VoiceConnection;
use crate::voice::opcodes::VoiceOpCode;
use serde_json::json;
use tokio::sync::mpsc;
use crate::voice::connection::VoiceEvent;
pub struct StreamConnection {
pub inner: VoiceConnection,
pub stream_key: Option<String>,
pub server_id: Option<String>,
}
impl StreamConnection {
pub fn new(
guild_id: Option<String>,
channel_id: String,
bot_id: String,
event_tx: mpsc::UnboundedSender<VoiceEvent>,
) -> Self {
Self {
inner: VoiceConnection::new(guild_id, channel_id, bot_id, event_tx),
stream_key: None,
server_id: None,
}
}
pub fn dave_channel_id(&self) -> Option<u64> {
self.server_id
.as_deref()
.and_then(|s| s.parse::<u64>().ok())
.map(|id| id.saturating_sub(1))
}
pub fn server_id(&self) -> Option<&str> {
self.server_id.as_deref()
}
}