Struct serenity::model::guild::Emoji[][src]

#[non_exhaustive]
pub struct Emoji { pub animated: bool, pub available: bool, pub id: EmojiId, pub name: String, pub managed: bool, pub require_colons: bool, pub roles: Vec<RoleId>, pub user: Option<User>, }
Expand description

Represents a custom guild emoji, which can either be created using the API, or via an integration. Emojis created using the API only work within the guild it was created in.

Fields (Non-exhaustive)

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
animated: bool

Whether the emoji is animated.

available: bool

Whether the emoji can be used. This may be false when the guild loses boosts, reducing the emoji limit.

id: EmojiId

The Id of the emoji.

name: String

The name of the emoji. It must be at least 2 characters long and can only contain alphanumeric characters and underscores.

managed: bool

Whether the emoji is managed via an Integration service.

require_colons: bool

Whether the emoji name needs to be surrounded by colons in order to be used by the client.

roles: Vec<RoleId>

A list of Roles that are allowed to use the emoji. If there are no roles specified, then usage is unrestricted.

user: Option<User>

The user who created the emoji.

Implementations

Deletes the emoji. This method requires the cache to fetch the guild ID.

Note: The Manage Emojis permission is required.

Examples

Delete a given emoji:

// assuming emoji has been set already
match emoji.delete(&ctx).await {
    Ok(()) => println!("Emoji deleted."),
    Err(_) => println!("Could not delete emoji."),
}
Errors

Returns Error::Http if the current user lacks permission, or may return ModelError::ItemMissing if the emoji is not in the cache.

Edits the emoji by updating it with a new name. This method requires the cache to fetch the guild ID.

Note: The Manage Emojis permission is required.

Errors

Returns Error::Http if the current user lacks permission, or if an invalid name is given.

Finds the Guild that owns the emoji by looking through the Cache.

Examples

Print the guild id that owns this emoji:

// assuming emoji has been set already
if let Some(guild_id) = emoji.find_guild_id(&cache).await {
    println!("{} is owned by {}", emoji.name, guild_id);
}

Generates a URL to the emoji’s image.

Examples

Print the direct link to the given emoji:

// assuming emoji has been set already
println!("Direct link to emoji image: {}", emoji.url());

Trait Implementations

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.

The associated error which can be returned from parsing.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the emoji into a string that will cause Discord clients to render the emoji.

This is in the format of either <:NAME:EMOJI_ID> for normal emojis, or <a:NAME:EMOJI_ID> for animated emojis.

Performs the conversion.

Gets the Id of an Emoji.

Performs the conversion.

Gets the Id of an Emoji.

Creates a Mention that will be able to notify or create a link to the item. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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