Skip to content

Commit

Permalink
Fix User::nick_in unconditionally returning if the cache is passed
Browse files Browse the repository at this point in the history
To be precise, when the user passes the cache to the function, it won't attempt to retrieve the nickname via HTTP at all if the guild or member do not exist.
  • Loading branch information
arqunis committed Aug 9, 2020
1 parent 550a63c commit 9c198ed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/model/user.rs
Expand Up @@ -789,9 +789,11 @@ impl User {
#[cfg(feature = "cache")]
{
if let Some(cache) = cache_http.cache() {
return guild_id.to_guild_cached(cache).and_then(|guild| {
guild.read().members.get(&self.id).and_then(|member| member.nick.clone())
});
if let Some(guild) = guild_id.to_guild_cached(cache) {
if let Some(member) = guild.read().members.get(&self.id) {
return member.nick.clone();
}
}
}
}

Expand Down

0 comments on commit 9c198ed

Please sign in to comment.