diff options
Diffstat (limited to 'src/system/plugin/reproxy.rs')
-rw-r--r-- | src/system/plugin/reproxy.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/system/plugin/reproxy.rs b/src/system/plugin/reproxy.rs index 145bed8..30b0c93 100644 --- a/src/system/plugin/reproxy.rs +++ b/src/system/plugin/reproxy.rs @@ -27,19 +27,11 @@ impl<'system> SeancePlugin<'system> for Reproxy { async fn handle_message<'message>(&self, logger: &'system Logger, system: &'system System, message: &'message Message, response: &'message mut Response) { if let Response::Proxy { member, content } = response { if content.as_str().trim() == "*" { - let most_recent_message = system.get_most_recent_message(message.channel_id).await; - if let Some((reproxy_target, update_most_recent)) = match message.kind { - twilight_model::channel::message::MessageType::Regular => most_recent_message.map(|(message, _)| (message, true)), - twilight_model::channel::message::MessageType::Reply => async {Some(( - message.referenced_message.as_ref()?.as_ref().clone(), - message.referenced_message.as_ref()?.id == most_recent_message?.0.id - ))}.await, - _ => todo!(), - } { + if let Some((reproxy_target, is_most_recent)) = system.resolve_message_target(message).await { if let Ok(new_message) = util::duplicate_message(&member.client, &reproxy_target, reproxy_target.content.as_str()).await { let _ = {member.client.lock().await.delete_message(reproxy_target.channel_id, reproxy_target.id).await}; - if update_most_recent { + if is_most_recent { system.cache_most_recent_message(new_message.channel_id, new_message, member.clone()).await; } |