mirror of
https://github.com/revanced/revanced-discord-bot.git
synced 2025-04-29 22:14:28 +02:00
feat: respond to message reference
This commit is contained in:
parent
32630c7434
commit
aba93d89cd
@ -41,8 +41,9 @@
|
||||
},
|
||||
"thread_options": {
|
||||
"lock_on_response": false,
|
||||
"close_on_response": false,
|
||||
}
|
||||
"close_on_response": false
|
||||
},
|
||||
"respond_to_reference": false
|
||||
}
|
||||
]
|
||||
}
|
@ -160,7 +160,8 @@
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"respond_to_reference": true
|
||||
},
|
||||
{
|
||||
"includes": {
|
||||
@ -196,7 +197,8 @@
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"respond_to_reference": true
|
||||
},
|
||||
{
|
||||
"includes": {
|
||||
@ -247,7 +249,8 @@
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"respond_to_reference": true
|
||||
},
|
||||
{
|
||||
"includes": {
|
||||
@ -308,7 +311,8 @@
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"respond_to_reference": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ pub struct MessageResponse {
|
||||
pub condition: Option<Condition>,
|
||||
pub response: Response,
|
||||
pub thread_options: Option<ThreadOptions>,
|
||||
pub respond_to_reference: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -82,9 +82,32 @@ pub async fn handle_message_response(ctx: &serenity::Context, new_message: &sere
|
||||
|
||||
let channel_id = new_message.channel_id;
|
||||
|
||||
let mut message_reference: Option<&serenity::Message> = None;
|
||||
|
||||
// If the message has a reference and the response is set to respond to references, respond to the reference
|
||||
if let Some(respond_to_reference) = response.respond_to_reference {
|
||||
if respond_to_reference {
|
||||
if let Some(reference) = &new_message.referenced_message {
|
||||
message_reference = Some(reference.as_ref());
|
||||
if let Err(err) = new_message.delete(&ctx.http).await {
|
||||
error!(
|
||||
"Failed to delete the message from {}. Error: {:?}",
|
||||
new_message.author.tag(),
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(err) = channel_id
|
||||
.send_message(&ctx.http, |m| {
|
||||
m.reference_message(new_message);
|
||||
if let Some(reference) = message_reference {
|
||||
m.reference_message(reference);
|
||||
} else {
|
||||
m.reference_message(new_message);
|
||||
}
|
||||
|
||||
match &response.response.embed {
|
||||
Some(embed) => m.embed(|e| {
|
||||
e.title(&embed.title)
|
||||
|
Loading…
x
Reference in New Issue
Block a user