Struct serenity::builder::CreateCommand
source · pub struct CreateCommand { /* private fields */ }
builder
only.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.
Trait Implementations§
source§impl Builder for CreateCommand
Available on crate feature http
only.
impl Builder for CreateCommand
http
only.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.
§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