Trait serenity::utils::ArgumentConvert[][src]

pub trait ArgumentConvert: Sized {
    type Err;
    fn convert<'life0, 'life1, 'async_trait>(
        ctx: &'life0 Context,
        guild_id: Option<GuildId>,
        channel_id: Option<ChannelId>,
        s: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

Parse a value from a string in context of a received message.

This trait is a superset of std::str::FromStr. The difference is that this trait aims to support serenity-specific Discord types like Member or Message.

Trait implementations may do network requests as part of their parsing procedure.

Useful for implementing argument parsing in command frameworks.

Associated Types

The associated error which can be returned from parsing.

Required methods

Parses a string s as a command parameter of this type.

Implementors

Look up a Channel by a string case-insensitively.

Lookup are done via local guild. If in DMs, the global cache is used instead.

The cache feature needs to be enabled.

The lookup strategy is as follows (in order):

  1. Lookup by ID.
  2. Lookup by mention.
  3. Lookup by name.

Look up a ChannelCategory by a string case-insensitively.

Lookup is done by the global cache, hence the cache feature needs to be enabled.

For more information, see the ArgumentConvert implementation for Channel

Look up a GuildChannel by a string case-insensitively.

Lookup is done by the global cache, hence the cache feature needs to be enabled.

For more information, see the ArgumentConvert implementation for Channel

Look up a message by a string.

The lookup strategy is as follows (in order):

  1. Lookup by “{channel ID}-{message ID}” (retrieved by shift-clicking on “Copy ID”)
  2. Lookup by message ID (the message must be in the context channel)
  3. Lookup by message URL

Look up a Emoji.

Requires the cache feature to be enabled.

The lookup strategy is as follows (in order):

  1. Lookup by ID.
  2. Lookup by extracting ID from the emoji.
  3. Lookup by name.

Look up a Guild, either by ID or by a string case-insensitively.

Requires the cache feature to be enabled.

Look up a guild member by a string case-insensitively.

Requires the cache feature to be enabled.

The lookup strategy is as follows (in order):

  1. Lookup by ID.
  2. Lookup by mention.
  3. Lookup by name#discrim.
  4. Lookup by name
  5. Lookup by nickname

Look up a Role by a string case-insensitively.

Requires the cache feature to be enabled.

The lookup strategy is as follows (in order):

  1. Lookup by ID
  2. Lookup by mention.
  3. Lookup by name (case-insensitive)

Look up a user by a string case-insensitively.

Requires the cache feature to be enabled. If a user is not in cache, they will not be found!

The lookup strategy is as follows (in order):

  1. Lookup by ID.
  2. Lookup by mention.
  3. Lookup by name#discrim.
  4. Lookup by name