Gateway: Simplify return value of join/join_gateway (#157)

Replaces the annoying dual-return (i.e., created `Call` *and* `Result<x>`) with a single `Return<Call/ConnectionInfo>`. Users are now informed via that a `Call` is created -- thus, cleanup in event of connection failure is now their responsibility.

Tested using `cargo make ready`.

Closes #65.
This commit is contained in:
Kyle Simpson
2023-01-09 01:35:48 +00:00
parent 5d06a429a8
commit f2fbbfeb25
8 changed files with 30 additions and 452 deletions

View File

@@ -161,11 +161,11 @@ async fn join(ctx: &Context, msg: &Message) -> CommandResult {
.expect("Songbird Voice client placed in at initialisation.")
.clone();
let (handler_lock, _success) = manager.join(guild_id, connect_to).await;
// Attach an event handler to see notifications of all track errors.
let mut handler = handler_lock.lock().await;
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
// Attach an event handler to see notifications of all track errors.
let mut handler = handler_lock.lock().await;
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
}
Ok(())
}