pub struct CheckboxBuilder { /* private fields */ }Expand description
Builds a checkbox for a modal’s label: a single yes/no choice, never required (use a one-option checkbox group for that).
discord.js counterpart: CheckboxBuilder.
§Examples
use djs_builders::{CheckboxBuilder, ModalBuilder};
let modal = ModalBuilder::new("signup", "Sign up")
.label("Send me the newsletter", CheckboxBuilder::new("newsletter").default(true))
.build()
.unwrap();
assert_eq!(modal.components.len(), 1);Implementations§
Source§impl CheckboxBuilder
impl CheckboxBuilder
Source§impl CheckboxBuilder
impl CheckboxBuilder
Sourcepub fn id(self, id: i32) -> Self
pub fn id(self, id: i32) -> Self
Sets the component’s numeric identifier (Discord generates one otherwise); it must be unique in the message or modal.
discord.js counterpart: setId.
Sourcepub fn build(self) -> Result<Component, ValidationError>
pub fn build(self) -> Result<Component, ValidationError>
Checks the component (and what it contains) and returns it.
discord.js counterpart: toJSON of the component builders.
§Errors
The first ValidationError found; see the type docs
for the rules.
Sourcepub fn build_unchecked(self) -> Component
pub fn build_unchecked(self) -> Component
Returns the component without any check (D-180).
discord.js counterpart: toJSON of the component builders with validation off (disableValidators).
Trait Implementations§
Source§impl Clone for CheckboxBuilder
impl Clone for CheckboxBuilder
Source§impl Debug for CheckboxBuilder
impl Debug for CheckboxBuilder
impl Eq for CheckboxBuilder
Source§impl From<CheckboxBuilder> for Component
impl From<CheckboxBuilder> for Component
Source§fn from(builder: CheckboxBuilder) -> Self
fn from(builder: CheckboxBuilder) -> Self
Converts to this type from the input type.
Source§impl PartialEq for CheckboxBuilder
impl PartialEq for CheckboxBuilder
impl StructuralPartialEq for CheckboxBuilder
Auto Trait Implementations§
impl Freeze for CheckboxBuilder
impl RefUnwindSafe for CheckboxBuilder
impl Send for CheckboxBuilder
impl Sync for CheckboxBuilder
impl Unpin for CheckboxBuilder
impl UnsafeUnpin for CheckboxBuilder
impl UnwindSafe for CheckboxBuilder
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