Struct twilight_util::builder::command::CommandBuilder
source · [−]pub struct CommandBuilder(_);Available on crate feature
builder only.Expand description
Builder to create a Command.
Implementations
sourceimpl CommandBuilder
impl CommandBuilder
sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
kind: CommandType
) -> Self
pub fn new(
name: impl Into<String>,
description: impl Into<String>,
kind: CommandType
) -> Self
Create a new default Command builder.
sourcepub fn validate(self) -> Result<Self, CommandValidationError>
pub fn validate(self) -> Result<Self, CommandValidationError>
Ensure the command is valid.
Errors
Refer to the errors section of twilight_validate::command::command
for possible errors.
sourcepub const fn guild_id(self, guild_id: Id<GuildMarker>) -> Self
pub const fn guild_id(self, guild_id: Id<GuildMarker>) -> Self
Set the guild ID of the command.
Defaults to None.
sourcepub const fn default_member_permissions(
self,
default_member_permissions: Permissions
) -> Self
pub const fn default_member_permissions(
self,
default_member_permissions: Permissions
) -> Self
Set the default member permission required to run the command.
Defaults to None.
sourcepub const fn dm_permission(self, dm_permission: bool) -> Self
pub const fn dm_permission(self, dm_permission: bool) -> Self
Set whether the command is available in DMs.
Defaults to None.
sourcepub fn description_localizations<K: Into<String>, V: Into<String>>(
self,
localizations: impl IntoIterator<Item = (K, V)>
) -> Self
pub fn description_localizations<K: Into<String>, V: Into<String>>(
self,
localizations: impl IntoIterator<Item = (K, V)>
) -> Self
Set the localization dictionary for the command description.
Defaults to None.
sourcepub fn name_localizations<K: Into<String>, V: Into<String>>(
self,
localizations: impl IntoIterator<Item = (K, V)>
) -> Self
pub fn name_localizations<K: Into<String>, V: Into<String>>(
self,
localizations: impl IntoIterator<Item = (K, V)>
) -> Self
Set the localization dictionary for the command name.
Defaults to None.
sourcepub fn option(self, option: impl Into<CommandOption>) -> Self
pub fn option(self, option: impl Into<CommandOption>) -> Self
Add an option to the command.
Defaults to an empty list.
Trait Implementations
sourceimpl Clone for CommandBuilder
impl Clone for CommandBuilder
sourcefn clone(&self) -> CommandBuilder
fn clone(&self) -> CommandBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations
impl RefUnwindSafe for CommandBuilder
impl Send for CommandBuilder
impl Sync for CommandBuilder
impl Unpin for CommandBuilder
impl UnwindSafe for CommandBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more