pub struct CreateCommand { /* private fields */ }
Available on crate feature 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

source

pub fn new(name: impl Into<String>) -> Self

Creates a new builder with the given name, leaving all other fields empty.

source

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.

source

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", "γενέθλια")
source

pub fn kind(self, kind: CommandType) -> Self

Specifies the type of the application command.

source

pub fn default_member_permissions(self, permissions: Permissions) -> Self

Specifies the default permissions required to execute the command.

source

pub fn dm_permission(self, enabled: bool) -> Self

Specifies if the command is available in DMs.

source

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.

source

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", "祝你朋友生日快乐")
source

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.

source

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.

source

pub fn nsfw(self, nsfw: bool) -> Self

Whether this channel is marked NSFW (age-restricted)

Trait Implementations§

source§

impl Builder for CreateCommand

Available on crate feature 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,

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>)

Additional data that’s only required when sending a request off to the API.
§

type Built = Command

source§

impl Clone for CreateCommand

source§

fn clone(&self) -> CreateCommand

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CreateCommand

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Serialize for CreateCommand

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneDebuggableStorage for T

source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,