From cbc336cc6326c782ca0e01ed934ed86f5b5ffda0 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 10 Jul 2023 02:31:11 +0200 Subject: [PATCH] feat: add option to check for first thread message only --- configuration.example.json | 3 ++- configuration.revanced.json | 3 ++- src/model/application.rs | 1 + src/utils/message_response.rs | 12 +++++++----- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/configuration.example.json b/configuration.example.json index c15b7a5..d910f34 100644 --- a/configuration.example.json +++ b/configuration.example.json @@ -41,7 +41,8 @@ }, "thread_options": { "lock_on_response": false, - "close_on_response": false + "close_on_response": false, + "only_on_first_message": false }, "respond_to_reference": false } diff --git a/configuration.revanced.json b/configuration.revanced.json index 38812e7..6ad5db8 100644 --- a/configuration.revanced.json +++ b/configuration.revanced.json @@ -352,7 +352,8 @@ "respond_to_reference": true, "thread_options": { "close_on_response": true, - "lock_on_response": false + "lock_on_response": false, + "only_on_first_message": false } } ] diff --git a/src/model/application.rs b/src/model/application.rs index 8edbeed..da8bd6d 100644 --- a/src/model/application.rs +++ b/src/model/application.rs @@ -93,6 +93,7 @@ pub struct MessageResponse { pub struct ThreadOptions { pub close_on_response: bool, pub lock_on_response: bool, + pub only_on_first_message: bool, } #[derive(Serialize, Deserialize)] diff --git a/src/utils/message_response.rs b/src/utils/message_response.rs index e1b60ba..41fc87e 100644 --- a/src/utils/message_response.rs +++ b/src/utils/message_response.rs @@ -167,11 +167,13 @@ pub async fn handle_message_response(ctx: &serenity::Context, new_message: &sere } // only edit this thread if the message is the first one - if !channel_id - .messages(&ctx.http, |b| b.limit(1).before(new_message)) - .await - .unwrap() - .is_empty() + + if thread_options.only_on_first_message + && !channel_id + .messages(&ctx.http, |b| b.limit(1).before(new_message)) + .await + .unwrap() + .is_empty() { return; }