Skip to main content

RoleSelectMenuBuilder

Struct RoleSelectMenuBuilder 

Source
pub struct RoleSelectMenuBuilder { /* private fields */ }
Expand description

Builds a role select menu, which Discord fills with the server’s roles.

discord.js counterpart: RoleSelectMenuBuilder.

Implementations§

Source§

impl RoleSelectMenuBuilder

Source

pub fn new(custom_id: impl Into<CompactString>) -> Self

Creates a menu sending custom_id (1-100 characters) to your app.

discord.js counterpart: new RoleSelectMenuBuilder().setCustomId(customId).

Source

pub fn default_roles(self, ids: impl IntoIterator<Item = RoleId>) -> Self

Adds roles selected when the menu appears; their number must be within min_values and max_values.

discord.js counterpart: addDefaultRoles.

Source§

impl RoleSelectMenuBuilder

Source

pub fn placeholder(self, placeholder: impl Into<CompactString>) -> Self

Sets the text shown while nothing is selected (at most 150 characters).

discord.js counterpart: setPlaceholder.

Source

pub fn min_values(self, min_values: u8) -> Self

Sets how many items must be chosen at least (0-25; Discord’s default: 1).

discord.js counterpart: setMinValues.

Source

pub fn max_values(self, max_values: u8) -> Self

Sets how many items can be chosen at most (1-25, at least min_values; Discord’s default: 1).

discord.js counterpart: setMaxValues.

Source

pub fn disabled(self, disabled: bool) -> Self

Sets whether the menu is greyed out (messages only; modals reject it).

discord.js counterpart: setDisabled.

Source

pub fn required(self, required: bool) -> Self

Sets whether an answer is required when the menu is in a modal (default: yes; ignored in messages).

discord.js counterpart: setRequired.

Source

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.

Source

pub fn build(self) -> Result<Component, ValidationError>

Checks the menu and returns it as a [Component].

discord.js counterpart: toJSON of the select menu builders.

§Errors

The first ValidationError found: the custom_id (1-100 characters), the placeholder (at most 150), min_values (0-25) and max_values (1-25, at least min_values), then what the menu offers (see the type docs).

Source

pub fn build_unchecked(self) -> Component

Returns the menu without any check (D-180).

discord.js counterpart: toJSON of the select menu builders with validation off (disableValidators).

Trait Implementations§

Source§

impl Clone for RoleSelectMenuBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RoleSelectMenuBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RoleSelectMenuBuilder

Source§

impl From<RoleSelectMenuBuilder> for Component

Source§

fn from(menu: RoleSelectMenuBuilder) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RoleSelectMenuBuilder

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RoleSelectMenuBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.