Skip to content

Commit

Permalink
feat: add option to check for first thread message only
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jul 10, 2023
1 parent 6867816 commit cbc336c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion configuration.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion configuration.revanced.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
]
Expand Down
1 change: 1 addition & 0 deletions src/model/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
12 changes: 7 additions & 5 deletions src/utils/message_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cbc336c

Please sign in to comment.