pub struct CreateCommand { /* private fields */ }
Expand description
A builder for creating a new Command
.
Self::name
and Self::description
are required fields.
Discord docs:
Implementations§
Source§impl CreateCommand
impl CreateCommand
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a new builder with the given name, leaving all other fields empty.
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Specifies the name of the application command, replacing the current value as set in
Self::new
.
Note: Must be between 1 and 32 lowercase characters, matching r"^[\w-]{1,32}$"
. Two
global commands of the same app cannot have the same name. Two guild-specific commands of
the same app cannot have the same name.
Sourcepub fn name_localized(
self,
locale: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn name_localized( self, locale: impl Into<String>, name: impl Into<String>, ) -> Self
Specifies a localized name of the application command.
.name("birthday")
.name_localized("zh-CN", "生日")
.name_localized("el", "γενέθλια")
Sourcepub fn kind(self, kind: CommandType) -> Self
pub fn kind(self, kind: CommandType) -> Self
Specifies the type of the application command.
Sourcepub fn default_member_permissions(self, permissions: Permissions) -> Self
pub fn default_member_permissions(self, permissions: Permissions) -> Self
Specifies the default permissions required to execute the command.
Sourcepub fn dm_permission(self, enabled: bool) -> Self
pub fn dm_permission(self, enabled: bool) -> Self
Specifies if the command is available in DMs.
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Specifies the description of the application command.
Note: Must be between 1 and 100 characters long.
Sourcepub fn description_localized(
self,
locale: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn description_localized( self, locale: impl Into<String>, description: impl Into<String>, ) -> Self
Specifies a localized description of the application command.
.description("Wish a friend a happy birthday")
.description_localized("zh-CN", "祝你朋友生日快乐")
Sourcepub fn add_option(self, option: CreateCommandOption) -> Self
pub fn add_option(self, option: CreateCommandOption) -> Self
Adds an application command option for the application command.
Note: Application commands can have up to 25 options.
Sourcepub fn set_options(self, options: Vec<CreateCommandOption>) -> Self
pub fn set_options(self, options: Vec<CreateCommandOption>) -> Self
Sets all the application command options for the application command.
Note: Application commands can have up to 25 options.
Sourcepub fn add_integration_type(self, integration_type: InstallationContext) -> Self
pub fn add_integration_type(self, integration_type: InstallationContext) -> Self
Adds an installation context that this application command can be used in.
Sourcepub fn integration_types(
self,
integration_types: Vec<InstallationContext>,
) -> Self
pub fn integration_types( self, integration_types: Vec<InstallationContext>, ) -> Self
Sets the installation contexts that this application command can be used in.
Sourcepub fn add_context(self, context: InteractionContext) -> Self
pub fn add_context(self, context: InteractionContext) -> Self
Adds an interaction context that this application command can be used in.
Sourcepub fn contexts(self, contexts: Vec<InteractionContext>) -> Self
pub fn contexts(self, contexts: Vec<InteractionContext>) -> Self
Sets the interaction contexts that this application command can be used in.
Sourcepub fn handler(self, handler: EntryPointHandlerType) -> Self
pub fn handler(self, handler: EntryPointHandlerType) -> Self
Sets the command’s entry point handler type. Only valid for commands of type
PrimaryEntryPoint
.
Trait Implementations§
Source§impl Builder for CreateCommand
impl Builder for CreateCommand
Source§fn execute<'life0, 'async_trait>(
self,
cache_http: impl 'async_trait + CacheHttp,
ctx: Self::Context<'life0>,
) -> Pin<Box<dyn Future<Output = Result<Self::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
self,
cache_http: impl 'async_trait + CacheHttp,
ctx: Self::Context<'life0>,
) -> Pin<Box<dyn Future<Output = Result<Self::Built>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a Command
, overriding an existing one with the same name if it exists.
Providing a GuildId
will create a command in the corresponding Guild
. Otherwise, a
global command will be created.
Providing a CommandId
will edit the corresponding command.
§Errors
Returns Error::Http
if invalid data is given. See Discord’s docs for more details.
May also return Error::Json
if there is an error in deserializing the API response.
Source§type Context<'ctx> = (Option<GuildId>, Option<CommandId>)
type Context<'ctx> = (Option<GuildId>, Option<CommandId>)
type Built = Command
Source§impl Clone for CreateCommand
impl Clone for CreateCommand
Source§fn clone(&self) -> CreateCommand
fn clone(&self) -> CreateCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more