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
impl RoleSelectMenuBuilder
Sourcepub fn new(custom_id: impl Into<CompactString>) -> Self
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).
Sourcepub fn default_roles(self, ids: impl IntoIterator<Item = RoleId>) -> Self
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
impl RoleSelectMenuBuilder
Sourcepub fn placeholder(self, placeholder: impl Into<CompactString>) -> Self
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.
Sourcepub fn min_values(self, min_values: u8) -> Self
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.
Sourcepub fn max_values(self, max_values: u8) -> Self
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.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Sets whether the menu is greyed out (messages only; modals reject it).
discord.js counterpart: setDisabled.
Sourcepub fn required(self, required: bool) -> Self
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.
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 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).
Sourcepub fn build_unchecked(self) -> Component
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).