pub struct CreatePoll<Stage: Sealed> { /* private fields */ }
Implementations§
Source§impl CreatePoll<NeedsQuestion>
impl CreatePoll<NeedsQuestion>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder for creating a Poll.
This must be transitioned through in order, to provide all required fields.
use serenity::builder::{CreateMessage, CreatePoll, CreatePollAnswer};
let poll = CreatePoll::new()
.question("Cats or Dogs?")
.answers(vec![
CreatePollAnswer::new().emoji("🐱".to_string()).text("Cats!"),
CreatePollAnswer::new().emoji("🐶".to_string()).text("Dogs!"),
CreatePollAnswer::new().text("Neither..."),
])
.duration(std::time::Duration::from_secs(60 * 60 * 24 * 7));
let message = CreateMessage::new().poll(poll);
Sourcepub fn question(self, text: impl Into<String>) -> CreatePoll<NeedsAnswers>
pub fn question(self, text: impl Into<String>) -> CreatePoll<NeedsAnswers>
Sets the question to be polled.
Source§impl CreatePoll<NeedsAnswers>
impl CreatePoll<NeedsAnswers>
Sourcepub fn answers(
self,
answers: Vec<CreatePollAnswer>,
) -> CreatePoll<NeedsDuration>
pub fn answers( self, answers: Vec<CreatePollAnswer>, ) -> CreatePoll<NeedsDuration>
Sets the answers that can be picked from.
Source§impl CreatePoll<NeedsDuration>
impl CreatePoll<NeedsDuration>
Sourcepub fn duration(self, duration: Duration) -> CreatePoll<Ready>
pub fn duration(self, duration: Duration) -> CreatePoll<Ready>
Sets the duration for the Poll to run for.
This must be less than a week, and will be rounded to hours towards zero.
Source§impl<Stage: Sealed> CreatePoll<Stage>
impl<Stage: Sealed> CreatePoll<Stage>
Sourcepub fn layout_type(self, layout_type: PollLayoutType) -> Self
pub fn layout_type(self, layout_type: PollLayoutType) -> Self
Sets the layout type for the Poll to take.
This is currently only ever PollLayoutType::Default
, and is optional.
Sourcepub fn allow_multiselect(self) -> Self
pub fn allow_multiselect(self) -> Self
Allows users to select multiple answers for the Poll.
Trait Implementations§
Source§impl<Stage: Clone + Sealed> Clone for CreatePoll<Stage>
impl<Stage: Clone + Sealed> Clone for CreatePoll<Stage>
Source§fn clone(&self) -> CreatePoll<Stage>
fn clone(&self) -> CreatePoll<Stage>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<Stage: Debug + Sealed> Debug for CreatePoll<Stage>
impl<Stage: Debug + Sealed> Debug for CreatePoll<Stage>
Source§impl Default for CreatePoll<NeedsQuestion>
impl Default for CreatePoll<NeedsQuestion>
Auto Trait Implementations§
impl<Stage> Freeze for CreatePoll<Stage>where
Stage: Freeze,
impl<Stage> RefUnwindSafe for CreatePoll<Stage>where
Stage: RefUnwindSafe,
impl<Stage> Send for CreatePoll<Stage>where
Stage: Send,
impl<Stage> Sync for CreatePoll<Stage>where
Stage: Sync,
impl<Stage> Unpin for CreatePoll<Stage>where
Stage: Unpin,
impl<Stage> UnwindSafe for CreatePoll<Stage>where
Stage: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more