From dc44a0b4b3f3bc03cfd49ef65e40dce8381b3960 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 16 Jun 2024 22:33:24 +0200 Subject: [PATCH] osu: Try to find the right score when announcing --- youmubot-osu/src/discord/announcer.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/youmubot-osu/src/discord/announcer.rs b/youmubot-osu/src/discord/announcer.rs index 094ef44..64bf89b 100644 --- a/youmubot-osu/src/discord/announcer.rs +++ b/youmubot-osu/src/discord/announcer.rs @@ -252,7 +252,10 @@ impl<'a> CollectedScore<'a> { f.user(UserID::ID(user.id)).mode(event.mode) }) .await?; - let score = match scores.into_iter().next() { + let score = match scores + .into_iter() + .find(|s| (s.date - event.date).abs() < chrono::TimeDelta::seconds(5)) + { Some(v) => v, None => return Err(Error::msg("cannot get score for map...")), };