aboutsummaryrefslogtreecommitdiff
path: root/src/cache
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-09-09 20:15:52 -0700
committerZeyla Hellyer <[email protected]>2017-09-09 20:15:52 -0700
commit485ad299fec218ed3fd354f7207ce6160d803b06 (patch)
tree4ccbd3ac7e2cd7ea10b2fda6322fbbc6a1a9c4d3 /src/cache
parentDocument the standard_framework feature in README (diff)
downloadserenity-485ad299fec218ed3fd354f7207ce6160d803b06.tar.xz
serenity-485ad299fec218ed3fd354f7207ce6160d803b06.zip
Handle channel category deletion
Diffstat (limited to 'src/cache')
-rw-r--r--src/cache/cache_events_impl.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/cache/cache_events_impl.rs b/src/cache/cache_events_impl.rs
index e5a6f68..a1d2e82 100644
--- a/src/cache/cache_events_impl.rs
+++ b/src/cache/cache_events_impl.rs
@@ -121,24 +121,26 @@ impl CacheEventsImpl for super::Cache {
}
fn update_with_channel_delete(&mut self, event: &ChannelDeleteEvent) {
- let channel = match event.channel {
- Channel::Guild(ref channel) => channel,
+ match event.channel {
+ Channel::Guild(ref channel) => {
+ let (guild_id, channel_id) = channel.with(|channel| (channel.guild_id, channel.id));
+
+ self.channels.remove(&channel_id);
+
+ self.guilds.get_mut(&guild_id).and_then(|guild| {
+ guild.with_mut(|g| g.channels.remove(&channel_id))
+ });
+ },
+ Channel::Category(ref category) => {
+ let channel_id = category.with(|cat| cat.id);
+
+ self.categories.remove(&channel_id);
+ },
// We ignore these two due to the fact that the delete event for dms/groups
- // will _not_ fire
- // anymore.
+ // will _not_ fire anymore.
Channel::Private(_) |
Channel::Group(_) => unreachable!(),
- // TODO: Fix this later.
- Channel::Category(_) => unreachable!(),
};
-
- let (guild_id, channel_id) = channel.with(|channel| (channel.guild_id, channel.id));
-
- self.channels.remove(&channel_id);
-
- self.guilds.get_mut(&guild_id).and_then(|guild| {
- guild.with_mut(|g| g.channels.remove(&channel_id))
- });
}
#[allow(dead_code)]