Skip to content

Commit 9560dd9

Browse files
committed
Fixed missing cache variable with "temp_cache" feature enabled
1 parent 357010d commit 9560dd9

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

src/model/channel/channel_id.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,22 @@ impl ChannelId {
5555
guild_id: Option<GuildId>,
5656
) -> Result<GuildChannel> {
5757
#[cfg(feature = "cache")]
58-
if let Some(cache) = cache_http.cache()
59-
&& let Some(guild_id) = guild_id
60-
&& let Some(guild) = cache.guild(guild_id)
61-
&& let Some(channel) = guild.channels.get(&self)
62-
{
63-
return Ok(channel.clone());
64-
}
65-
66-
#[cfg(feature = "temp_cache")]
67-
if let Some(temp_channel) = cache.temp_channels.get(&self) {
68-
if guild_id.is_some_and(|id| temp_channel.base.guild_id != id) {
69-
return Err(Error::Model(ModelError::ChannelNotFound));
58+
if let Some(cache) = cache_http.cache() {
59+
if let Some(guild_id) = guild_id
60+
&& let Some(guild) = cache.guild(guild_id)
61+
&& let Some(channel) = guild.channels.get(&self)
62+
{
63+
return Ok(channel.clone());
7064
}
7165

72-
return Ok(GuildChannel::clone(&temp_channel));
66+
#[cfg(feature = "temp_cache")]
67+
if let Some(temp_channel) = cache.temp_channels.get(&self) {
68+
if guild_id.is_some_and(|id| temp_channel.base.guild_id != id) {
69+
return Err(Error::Model(ModelError::ChannelNotFound));
70+
}
71+
72+
return Ok(GuildChannel::clone(&temp_channel));
73+
}
7374
}
7475

7576
let channel = cache_http.http().get_channel(self.widen()).await?;

src/model/channel/thread.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,22 @@ impl ThreadId {
3333
guild_id: Option<GuildId>,
3434
) -> Result<GuildThread> {
3535
#[cfg(feature = "cache")]
36-
if let Some(cache) = cache_http.cache()
37-
&& let Some(guild_id) = guild_id
38-
&& let Some(guild) = cache.guild(guild_id)
39-
&& let Some(thread) = guild.threads.get(&self)
40-
{
41-
return Ok(thread.clone());
42-
}
43-
44-
#[cfg(feature = "temp_cache")]
45-
if let Some(temp_thread) = cache.temp_threads.get(&self) {
46-
if guild_id.is_some_and(|id| temp_thread.base.guild_id != id) {
47-
return Err(Error::Model(ModelError::ChannelNotFound));
36+
if let Some(cache) = cache_http.cache() {
37+
if let Some(guild_id) = guild_id
38+
&& let Some(guild) = cache.guild(guild_id)
39+
&& let Some(thread) = guild.threads.get(&self)
40+
{
41+
return Ok(thread.clone());
4842
}
4943

50-
return Ok(GuildThread::clone(&temp_thread));
44+
#[cfg(feature = "temp_cache")]
45+
if let Some(temp_thread) = cache.temp_threads.get(&self) {
46+
if guild_id.is_some_and(|id| temp_thread.base.guild_id != id) {
47+
return Err(Error::Model(ModelError::ChannelNotFound));
48+
}
49+
50+
return Ok(GuildThread::clone(&temp_thread));
51+
}
5152
}
5253

5354
let channel = cache_http.http().get_channel(self.widen()).await?;

0 commit comments

Comments
 (0)