Skip to content

Commit

Permalink
Don't hold the existing calls until after successfully joining
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Oct 18, 2024
1 parent 94afe42 commit 3b741cb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripty_audio_handler/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub async fn connect_to_vc(
let ctx_data = get_data(&ctx);

debug!(%guild_id, "checking if call already exists");
if let Some(existing) = ctx_data.existing_calls.insert(guild_id, voice_channel_id) {
if let Some(existing) = ctx_data.existing_calls.get(&guild_id) {
// call already exists, if channel ID != current one continue as we need to switch VCs
if existing == voice_channel_id {

Check failure on line 32 in scripty_audio_handler/src/connect.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

binary operation `==` cannot be applied to type `dashmap::mapref::one::Ref<'_, serenity::all::GuildId, serenity::all::ChannelId>`

error[E0369]: binary operation `==` cannot be applied to type `dashmap::mapref::one::Ref<'_, serenity::all::GuildId, serenity::all::ChannelId>` --> scripty_audio_handler/src/connect.rs:32:15 | 32 | if existing == voice_channel_id { | -------- ^^ ---------------- serenity::all::ChannelId | | | dashmap::mapref::one::Ref<'_, serenity::all::GuildId, serenity::all::ChannelId> | note: the foreign item type `dashmap::mapref::one::Ref<'_, serenity::all::GuildId, serenity::all::ChannelId>` doesn't implement `std::cmp::PartialEq<serenity::all::ChannelId>` --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dashmap-6.1.0/src/mapref/one.rs:7:1 | 7 | pub struct Ref<'a, K, V> { | ^^^^^^^^^^^^^^^^^^^^^^^^ not implement `std::cmp::PartialEq<serenity::all::ChannelId>`
// attempting to rejoin the same channel, so return early
Expand Down Expand Up @@ -196,5 +196,7 @@ pub async fn connect_to_vc(
}
});

ctx_data.existing_calls.insert(guild_id, voice_channel_id);

Ok(())
}

0 comments on commit 3b741cb

Please sign in to comment.