Skip to content

Commit 50a9abb

Browse files
committed
CreatePoll uses u8 for the expiry hours, despite Discord docs now allowing up to 32 days
Fixes #3365
1 parent 03c6681 commit 50a9abb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/builder/create_poll.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct CreatePollMedia {
3333
pub struct CreatePoll<Stage: Sealed> {
3434
question: CreatePollMedia,
3535
answers: Vec<CreatePollAnswer>,
36-
duration: u8,
36+
duration: u16,
3737
allow_multiselect: bool,
3838
layout_type: Option<PollLayoutType>,
3939

@@ -51,7 +51,7 @@ impl Default for CreatePoll<NeedsQuestion> {
5151
text: String::default(),
5252
},
5353
answers: Vec::default(),
54-
duration: u8::default(),
54+
duration: u16::default(),
5555
allow_multiselect: false,
5656
layout_type: None,
5757

@@ -115,14 +115,16 @@ impl CreatePoll<NeedsAnswers> {
115115
impl CreatePoll<NeedsDuration> {
116116
/// Sets the duration for the Poll to run for.
117117
///
118-
/// This must be less than a week, and will be rounded to hours towards zero.
118+
/// This must be at most 32 days, and will be rounded to hours towards zero.
119119
pub fn duration(self, duration: std::time::Duration) -> CreatePoll<Ready> {
120+
const DAYS_32: u16 = 768;
121+
120122
let hours = duration.as_secs() / 3600;
121123

122124
CreatePoll {
123125
question: self.question,
124126
answers: self.answers,
125-
duration: hours.try_into().unwrap_or(168),
127+
duration: hours.try_into().unwrap_or(DAYS_32),
126128
allow_multiselect: self.allow_multiselect,
127129
layout_type: self.layout_type,
128130
_stage: Ready,

0 commit comments

Comments
 (0)