From 4fa4907c3da23249ddec2bcb50e48f708152059e Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Sat, 5 Oct 2024 13:11:46 -0600 Subject: Rudimentary message parsing and upgraded time dep for 1.80.0 --- src/system/bot/client.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/system/bot/client.rs') 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 { let client = self.client.lock().await; -- cgit 1.4.1