pub struct CommandBuilder(/* private fields */);
Available on crate feature
builder
only.Expand description
Builder to create a [Command
].
Implementations§
Source§impl 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 fn contexts(
self,
contexts: impl IntoIterator<Item = InteractionContextType>,
) -> Self
pub fn contexts( self, contexts: impl IntoIterator<Item = InteractionContextType>, ) -> Self
Set the contexts of the command.
Defaults to nothing.
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
👎Deprecated: use contexts instead
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 integration_types(
self,
integration_types: impl IntoIterator<Item = ApplicationIntegrationType>,
) -> Self
pub fn integration_types( self, integration_types: impl IntoIterator<Item = ApplicationIntegrationType>, ) -> Self
Set the integration types for the command.
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
.
Trait Implementations§
Source§impl Clone for CommandBuilder
impl Clone for CommandBuilder
Source§fn clone(&self) -> CommandBuilder
fn clone(&self) -> CommandBuilder
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for CommandBuilder
impl RefUnwindSafe for CommandBuilder
impl Send for CommandBuilder
impl Sync for CommandBuilder
impl Unpin for CommandBuilder
impl UnwindSafe for CommandBuilder
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