feat(api): also clear cache when leaving a guild

This commit is contained in:
sam 2024-10-24 21:10:54 +02:00
parent 5c57b75335
commit 439051999f
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
10 changed files with 53 additions and 0 deletions

View file

@ -81,4 +81,17 @@ public class ChannelCache
.Select(id => _channels.GetValueOrDefault(id))
.Where(c => c != null)
.Select(c => c!);
public void RemoveGuild(Snowflake guildId)
{
if (!_guildChannels.TryGetValue(guildId, out var channelIds))
return;
foreach (var id in channelIds)
{
_channels.Remove(id, out _);
}
_guildChannels.Remove(guildId, out _);
}
}