Skip to content

Commit

Permalink
fix: handle case when old channel and new channel are the same in Voi…
Browse files Browse the repository at this point in the history
…ceStateUpdate event

Co-authored-by: hiraginoyuki <[email protected]>
  • Loading branch information
Mogyuchi and hiraginoyuki committed Feb 9, 2024
1 parent ddb81e2 commit 8d3f603
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ async fn event_handler(
println!("Logged in as {}", data_about_bot.user.name);
}

serenity::FullEvent::VoiceStateUpdate { old: _, new } => {
serenity::FullEvent::VoiceStateUpdate { old, new } => {
// old があるかつ old channel と new channel が一致していたら何もしない
if old
.as_ref()
.is_some_and(|old| old.channel_id == new.channel_id)
{
return Ok(());
}

let Some(new_channel_id) = new.channel_id else {
return Ok(());
};
Expand Down

0 comments on commit 8d3f603

Please sign in to comment.