summary refs log tree commit diff
path: root/src/system/bot
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2024-10-06 15:25:01 -0600
committerAshelyn Rose <git@ashen.earth>2024-10-06 15:25:01 -0600
commitec104a719f46d6812661c29355e7a9fea8418b49 (patch)
tree378eadd6183f5c9af997e52f89bdfa59570b0f7a /src/system/bot
parent9e15bb9103ba054fa88501cbff2d5e121ffa8544 (diff)
Actually carries out !edit and !s commands
Diffstat (limited to 'src/system/bot')
-rw-r--r--src/system/bot/client.rs7
-rw-r--r--src/system/bot/mod.rs4
2 files changed, 11 insertions, 0 deletions
diff --git a/src/system/bot/client.rs b/src/system/bot/client.rs
index 61d7515..4d4f7bb 100644
--- a/src/system/bot/client.rs
+++ b/src/system/bot/client.rs
@@ -90,6 +90,13 @@ impl Client {
         return Ok(())
     }
 
+    pub async fn edit_message(&self, channel_id: ChannelId, message_id: MessageId, new_content: String) -> Result<FullMessage, TwiError> {
+        Ok(self.client.lock().await.update_message(channel_id, message_id)
+            .content(Some(new_content.as_str())).expect("Invalid message contents")
+            .await.expect("Could not update message")
+            .model().await.unwrap())
+    }
+
     pub async fn duplicate_message(&self, message: &TwiMessage, content: &str) -> Result<TwiMessage, MessageDuplicateError> {
         let client = self.client.lock().await;
 
diff --git a/src/system/bot/mod.rs b/src/system/bot/mod.rs
index 2f38075..f0a2e45 100644
--- a/src/system/bot/mod.rs
+++ b/src/system/bot/mod.rs
@@ -74,6 +74,10 @@ impl Bot {
         self.client.resend_message(message_id, channel_id).await;
     }
 
+    pub async fn edit_message(&self, channel_id: ChannelId, message_id: MessageId, new_content: String) -> Result<FullMessage, TwiError> {
+        self.client.edit_message(channel_id, message_id, new_content).await
+    }
+
     pub async fn delete_message(&self, channel_id: ChannelId, message_id: MessageId) -> Result<(), TwiError> {
         self.client.delete_message(channel_id, message_id).await
     }