feat: update to songbird 0.6, make joining calls work by spawning everything as required in songbird's documentation
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -170,6 +170,7 @@ async fn main() -> Result<(), MainError> {
|
||||
.expect("failed to deserialize set commands"); // TODO
|
||||
|
||||
let command_router = CommandRouter::from_iter(commands);
|
||||
let command_router = Arc::new(command_router);
|
||||
|
||||
let vcs = initialize_vcs(&discord_client).await;
|
||||
|
||||
@@ -187,7 +188,7 @@ async fn main() -> Result<(), MainError> {
|
||||
while let Some(event_res) = next_event.await {
|
||||
match event_res {
|
||||
Ok(event) => {
|
||||
handle_event(&command_router, state.clone(), event).await;
|
||||
handle_event(command_router.clone(), state.clone(), event).await;
|
||||
}
|
||||
Err(error) => {
|
||||
tracing::error!(?error);
|
||||
@@ -201,7 +202,7 @@ async fn main() -> Result<(), MainError> {
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(command_router))]
|
||||
async fn handle_event(command_router: &CommandRouter, state: State, event: Event) {
|
||||
async fn handle_event(command_router: Arc<CommandRouter>, state: State, event: Event) {
|
||||
state.songbird.process(&event).await;
|
||||
match event {
|
||||
Event::VoiceStateUpdate(voice_state_update) => {
|
||||
@@ -215,10 +216,12 @@ async fn handle_event(command_router: &CommandRouter, state: State, event: Event
|
||||
tracing::warn!("missing expected interaction data");
|
||||
}
|
||||
Some(InteractionData::ApplicationCommand(command_data)) => {
|
||||
let command_name = &command_data.name.clone();
|
||||
command_router
|
||||
.handle(state, command_name, interaction)
|
||||
.await;
|
||||
let command_name = command_data.name.clone();
|
||||
tokio::spawn(async move {
|
||||
command_router
|
||||
.handle(state, &command_name, interaction)
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
||||
Some(InteractionData::MessageComponent(component_data)) => {
|
||||
|
||||
Reference in New Issue
Block a user