feat: update to songbird 0.6, make joining calls work by spawning everything as required in songbird's documentation
This commit is contained in:
@@ -82,7 +82,7 @@ fn get_guild_and_channel_id(
|
||||
Ok((guild_id, channel_id))
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(state))]
|
||||
pub async fn handle(state: State, interaction: Interaction) {
|
||||
let vcs = state.vcs;
|
||||
|
||||
@@ -126,13 +126,22 @@ pub async fn handle(state: State, interaction: Interaction) {
|
||||
.await
|
||||
.expect("TODO");
|
||||
|
||||
let call = tokio::spawn({
|
||||
let songbird = state.songbird.clone();
|
||||
async move { songbird.join(guild_id, channel_id).await }
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.expect("TODO");
|
||||
let call = loop {
|
||||
tracing::error!("TODO: about to try joining");
|
||||
|
||||
match state.songbird.join(guild_id, channel_id).await {
|
||||
Ok(call) => break call,
|
||||
Err(error) => {
|
||||
tracing::error!(?error, "I'm still here");
|
||||
|
||||
if error.should_leave_server() {
|
||||
state.songbird.leave(guild_id).await.expect("TODO");
|
||||
} else if error.should_reconnect_driver() {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let channel_mention = format!("<#{channel_id}>");
|
||||
|
||||
@@ -150,4 +159,5 @@ pub async fn handle(state: State, interaction: Interaction) {
|
||||
tracing::error!(?call, "TODO");
|
||||
|
||||
let call_guard = call.lock().await;
|
||||
tracing::error!(?call_guard, "TODO");
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ pub struct State {
|
||||
}
|
||||
|
||||
type Return = ();
|
||||
type BoxedHandler = Box<dyn Fn(State, Interaction) -> BoxFuture<'static, Return>>;
|
||||
type BoxedHandler = Box<dyn Send + Sync + Fn(State, Interaction) -> BoxFuture<'static, Return>>;
|
||||
|
||||
fn box_handler<Handler, Fut>(handler: Handler) -> BoxedHandler
|
||||
where
|
||||
Fut: Future<Output = Return> + Send + 'static,
|
||||
Handler: Fn(State, Interaction) -> Fut + 'static,
|
||||
Handler: Send + Sync + Fn(State, Interaction) -> Fut + 'static,
|
||||
{
|
||||
Box::new(move |state, interaction| Box::pin(handler(state, interaction)))
|
||||
}
|
||||
@@ -50,7 +50,7 @@ impl Router {
|
||||
fn add_route<Fut, Handler>(&mut self, name: &str, handler: Handler)
|
||||
where
|
||||
Fut: Future<Output = Return> + Send + 'static,
|
||||
Handler: Fn(State, Interaction) -> Fut + 'static,
|
||||
Handler: Send + Sync + Fn(State, Interaction) -> Fut + 'static,
|
||||
{
|
||||
self.add_route_already_boxed(name, box_handler(handler));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user