Skip to content

CreatePoll uses u8 for the expiry hours, despite Discord docs now allowing up to 32 days #3365

@jamesbt365

Description

@jamesbt365

Official docs: https://discord.com/developers/docs/resources/poll#poll-create-request-object

pub struct CreatePoll<Stage: Sealed> {
question: CreatePollMedia,
answers: Vec<CreatePollAnswer>,
duration: u8,
allow_multiselect: bool,
layout_type: Option<PollLayoutType>,
#[serde(skip)]
_stage: Stage,
}

Note that the docs also need to be changed to mention the new limit.

impl CreatePoll<NeedsDuration> {
/// Sets the duration for the Poll to run for.
///
/// This must be less than a week, and will be rounded to hours towards zero.
pub fn duration(self, duration: std::time::Duration) -> CreatePoll<Ready> {
let hours = duration.as_secs() / 3600;
CreatePoll {
question: self.question,
answers: self.answers,
duration: hours.try_into().unwrap_or(168),
allow_multiselect: self.allow_multiselect,
layout_type: self.layout_type,
_stage: Ready,
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeThe public API is changed, resulting in miscompilations or unexpected new behaviour for usersbugSomething misbehaves or is not working.discord featureRelated to Discord's functionality.good first issueAn easy problem suited for people new to Rust or Serenity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions