From 330ff449705a5195713a10749a40991e9ad2a8d5 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Sat, 7 Oct 2023 19:33:10 +0100 Subject: [PATCH] Provide old thread data in `thread_update` (#2553) --- src/client/dispatch.rs | 5 +++-- src/client/event_handler.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 6ca92bcb2a0..a503043fbe2 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -468,11 +468,12 @@ fn update_cache_with_event(ctx: Context, event: Event) -> Option<(FullEvent, Opt } }, Event::ThreadUpdate(mut event) => { - update_cache(&ctx, &mut event); + let old = if_cache!(update_cache(&ctx, &mut event)); FullEvent::ThreadUpdate { ctx, - thread: event.thread, + old, + new: event.thread, } }, Event::ThreadDelete(mut event) => { diff --git a/src/client/event_handler.rs b/src/client/event_handler.rs index 9f475ba0059..49357acbea2 100644 --- a/src/client/event_handler.rs +++ b/src/client/event_handler.rs @@ -384,8 +384,8 @@ event_handler! { /// Dispatched when a thread is updated. /// - /// Provides the updated thread. - async fn thread_update(&self, ThreadUpdate { ctx: Context, thread: GuildChannel }); + /// Provides the updated thread and the old thread data, provided the thread was cached prior to dispatch. + async fn thread_update(&self, ThreadUpdate { ctx: Context, old: Option, new: GuildChannel }); /// Dispatched when a thread is deleted. ///