diff --git a/src/handler.rs b/src/handler.rs index f1159c37c..05f962c36 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -230,6 +230,16 @@ impl Call { self.update().await.map(|_| rx.into_recv_async()) } + /// Returns the current voice connection details for this Call, + /// if available. + #[instrument(skip(self))] + pub fn current_connection(&self) -> Option<&ConnectionInfo> { + match &self.connection { + Some((_, progress, _)) => progress.get_connection_info(), + _ => None, + } + } + /// Leaves the current voice channel, disconnecting from it. /// /// This does _not_ forget settings, like whether to be self-deafened or diff --git a/src/info.rs b/src/info.rs index 8b3fdb36c..1adbe05e8 100644 --- a/src/info.rs +++ b/src/info.rs @@ -16,6 +16,14 @@ impl ConnectionProgress { }) } + pub(crate) fn get_connection_info(&self) -> Option<&ConnectionInfo> { + use ConnectionProgress::*; + match self { + Complete(c) => Some(&c), + _ => None, + } + } + pub(crate) fn apply_state_update(&mut self, session_id: String) -> bool { use ConnectionProgress::*; match self {