feat: add option to check for first thread message only

This commit is contained in:
oSumAtrIX 2023-07-10 02:31:11 +02:00
parent 6867816272
commit cbc336cc63
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
4 changed files with 12 additions and 7 deletions

View File

@ -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
}

View File

@ -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
}
}
]

View File

@ -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)]

View File

@ -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;
}