summary refs log tree commit diff
path: root/src/system/bot/client.rs
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2024-10-05 18:02:12 -0600
committerAshelyn Rose <git@ashen.earth>2024-10-05 18:02:12 -0600
commitca4b0e32be531053f19ce2895b994130b247af4a (patch)
treebdfef248c6917109b6a768bed9733b0999ae0e2f /src/system/bot/client.rs
parent4fa4907c3da23249ddec2bcb50e48f708152059e (diff)
Add sent-message cache for looking up command targets
Diffstat (limited to 'src/system/bot/client.rs')
-rw-r--r--src/system/bot/client.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/system/bot/client.rs b/src/system/bot/client.rs
index 006ce8f..61d7515 100644
--- a/src/system/bot/client.rs
+++ b/src/system/bot/client.rs
@@ -23,18 +23,22 @@ impl Client {
         }
     }
 
-    pub async fn refetch_message(&self, message_id: MessageId, channel_id: ChannelId) {
+    pub async fn fetch_message(&self, message_id: MessageId, channel_id: ChannelId) -> FullMessage {
         let client = self.client.lock().await;
-        let bot_conf = self.bot_conf.read().await;
-        let message_channel = bot_conf.message_handler.as_ref().expect("No message handler");
 
-        let message = client
+        client
             .message(channel_id, message_id)
             .await
             .expect("Could not load message")
             .model()
             .await
-            .expect("Could not deserialize message");
+            .expect("Could not deserialize message")
+    }
+
+    pub async fn resend_message(&self, message_id: MessageId, channel_id: ChannelId) {
+        let bot_conf = self.bot_conf.read().await;
+        let message = self.fetch_message(message_id, channel_id).await;
+        let message_channel = bot_conf.message_handler.as_ref().expect("No message handler");
 
         let timestamp = if message.edited_timestamp.is_some() {
             message.edited_timestamp.unwrap()
@@ -43,7 +47,7 @@ impl Client {
         };
 
         message_channel
-            .send((timestamp, Message::Complete(message)))
+            .send((timestamp, Message::Complete(message, bot_conf.member_id)))
             .await;
     }