#[non_exhaustive]pub struct CreatePoll {
pub question: Media,
pub answers: Vec<Media>,
pub duration: Option<u32>,
pub allow_multiselect: Option<bool>,
pub layout_type: Option<LayoutType>,
}Expand description
A poll to create, sent with a new message or an interaction response.
discord.js counterpart: PollData (the poll option of message create options).
§Examples
use djs_model::poll::{CreatePoll, Media};
let mut poll = CreatePoll::new("Tabs or spaces?", [Media::new("Tabs"), Media::new("Spaces")]);
poll.duration = Some(24);
assert_eq!(
serde_json::to_string(&poll).unwrap(),
concat!(
r#"{"question":{"text":"Tabs or spaces?"},"answers":[{"poll_media":{"text":"Tabs"}},"#,
r#"{"poll_media":{"text":"Spaces"}}],"duration":24}"#,
)
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.question: MediaThe question (text only, max 300 characters).
answers: Vec<Media>The answers (up to 10; text max 55 characters, optionally an emoji), written as answer objects without IDs.
duration: Option<u32>How long the poll is open, in hours (up to 32 days; Discord’s default is 24 hours).
allow_multiselect: Option<bool>Whether users can select several answers (Discord’s default: false).
layout_type: Option<LayoutType>The layout (Discord’s default: LayoutType::Default).
Implementations§
Source§impl CreatePoll
impl CreatePoll
Sourcepub fn new(
question: impl Into<CompactString>,
answers: impl IntoIterator<Item = Media>,
) -> Self
pub fn new( question: impl Into<CompactString>, answers: impl IntoIterator<Item = Media>, ) -> Self
Creates a poll with Discord’s defaults for everything else.
discord.js counterpart: PollData.
Trait Implementations§
Source§impl Clone for CreatePoll
impl Clone for CreatePoll
Source§impl Debug for CreatePoll
impl Debug for CreatePoll
Source§impl<'de> Deserialize<'de> for CreatePoll
impl<'de> Deserialize<'de> for CreatePoll
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CreatePoll
Source§impl PartialEq for CreatePoll
impl PartialEq for CreatePoll
Source§impl Serialize for CreatePoll
impl Serialize for CreatePoll
impl StructuralPartialEq for CreatePoll
Auto Trait Implementations§
impl Freeze for CreatePoll
impl RefUnwindSafe for CreatePoll
impl Send for CreatePoll
impl Sync for CreatePoll
impl Unpin for CreatePoll
impl UnsafeUnpin for CreatePoll
impl UnwindSafe for CreatePoll
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