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 13:11:46 -0600
committerAshelyn Rose <git@ashen.earth>2024-10-05 13:11:46 -0600
commit4fa4907c3da23249ddec2bcb50e48f708152059e (patch)
treec30305c4da0a0b81023af8f4c36681a583d80152 /src/system/bot/client.rs
parent8d564bb8a17b5b0251805baf20c6741d4d20e501 (diff)
Rudimentary message parsing and upgraded time dep for 1.80.0
Diffstat (limited to 'src/system/bot/client.rs')
-rw-r--r--src/system/bot/client.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/system/bot/client.rs b/src/system/bot/client.rs
index c55759a..006ce8f 100644
--- a/src/system/bot/client.rs
+++ b/src/system/bot/client.rs
@@ -52,6 +52,8 @@ impl Client {
         let delete_result = client.delete_message(channel_id, message_id).await;
         let member_id = self.bot_conf.read().await.member_id;
 
+        drop(client);
+
         match delete_result {
             Err(err) => {
                 match &err.kind() {
@@ -60,11 +62,7 @@ impl Client {
                             // Code for "Missing Permissions": https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes
                             if err.code == 50013 {
                                 println!("ERROR: Client {} doesn't have permissions to delete message", member_id);
-                                let _ = client.create_reaction(
-                                    channel_id,
-                                    message_id,
-                                    &RequestReactionType::Unicode { name: "🔐" }
-                                ).await;
+                                let _ = self.react_message(channel_id, message_id, &RequestReactionType::Unicode { name: "🔐" }).await;
                             }
                         },
                         _ => (),
@@ -78,6 +76,16 @@ impl Client {
         }
     }
 
+    pub async fn react_message(&self, channel_id: ChannelId, message_id: MessageId, react: &'_ RequestReactionType<'_>) -> Result<(), TwiError> {
+        let _ = self.client.lock().await.create_reaction(
+            channel_id,
+            message_id,
+            react
+        ).await;
+
+        return Ok(())
+    }
+
     pub async fn duplicate_message(&self, message: &TwiMessage, content: &str) -> Result<TwiMessage, MessageDuplicateError> {
         let client = self.client.lock().await;