feat: add option to enable or disable pings when polling

This commit is contained in:
oSumAtrIX 2023-03-27 21:34:18 +02:00
parent 0793b1c6d1
commit 3e86a2cdb7
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -51,8 +51,9 @@ pub async fn reply(
pub async fn poll(
ctx: Context<'_>,
#[description = "The id of the poll"] id: u64, /* This is currently unused in the API, leaving as a placeholder in case it is required. */
#[description = "The link to a message to clone"] message_link: String,
#[description = "A link to a message to clone"] message_link: String,
#[description = "The minumum server age in days to allow members to poll"] age: u16,
#[description = "Enable pings"] ping: bool,
) -> Result<(), Error> {
let get_id =
|segments: &mut std::str::Split<char>| segments.next_back().unwrap().parse::<u64>();
@ -74,8 +75,7 @@ pub async fn poll(
.await?;
ctx.send(|m| {
clone_message(&message, m)
.components(|c| {
let mut clone = clone_message(&message, m).components(|c| {
c.create_action_row(|r| {
r.create_button(|b| {
b.label("Vote")
@ -83,12 +83,17 @@ pub async fn poll(
.custom_id(format!("poll:{id}:{age}"))
})
})
})
.allowed_mentions(|am| {
});
if ping {
clone = clone.allowed_mentions(|am| {
am.parse(ParseValue::Users)
.parse(ParseValue::Roles)
.parse(ParseValue::Everyone)
})
});
}
clone
})
.await?;