Skip to content

Commit

Permalink
Re-add cache fetching to GuildId::member (#2799)
Browse files Browse the repository at this point in the history
This was mistakenly removed in #2794 but is still possible here as we
have the `GuildId`.
  • Loading branch information
GnomedDev authored Mar 16, 2024
1 parent 5a4d30d commit ade0b2b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/model/guild/guild_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,20 @@ impl GuildId {
cache_http: impl CacheHttp,
user_id: impl Into<UserId>,
) -> Result<Member> {
cache_http.http().get_member(self, user_id.into()).await
let user_id = user_id.into();

#[cfg(feature = "cache")]
{
if let Some(cache) = cache_http.cache() {
if let Some(guild) = cache.guild(self) {
if let Some(member) = guild.members.get(&user_id) {
return Ok(member.clone());
}
}
}
}

cache_http.http().get_member(self, user_id).await
}

/// Gets a list of the guild's members.
Expand Down

0 comments on commit ade0b2b

Please sign in to comment.