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

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

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)

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.

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.

Implementations

impl Emoji[src]

pub async fn delete<T: AsRef<Cache> + AsRef<Http>>(
    &self,
    cache_http: T
) -> Result<()>
[src]

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

Note: The Manage Emojis permission is required.

Note: Only user accounts may use this method.

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.")
}

pub async fn edit<T: AsRef<Cache> + AsRef<Http>>(
    &mut self,
    cache_http: T,
    name: &str
) -> Result<()>
[src]

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.

Note: Only user accounts may use this method.

pub async fn find_guild_id(&self, cache: impl AsRef<Cache>) -> Option<GuildId>[src]

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

pub fn url(&self) -> String[src]

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

impl Clone for Emoji[src]

impl Debug for Emoji[src]

impl<'de> Deserialize<'de> for Emoji[src]

impl Display for Emoji[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult[src]

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.

impl From<&'_ Emoji> for Mention[src]

impl<'a> From<&'a Emoji> for EmojiId[src]

pub fn from(emoji: &Emoji) -> EmojiId[src]

Gets the Id of an Emoji.

impl From<Emoji> for ReactionType[src]

impl From<Emoji> for EmojiId[src]

pub fn from(emoji: Emoji) -> EmojiId[src]

Gets the Id of an Emoji.

impl Mentionable for Emoji[src]

impl Serialize for Emoji[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

impl<T> WithSubscriber for T[src]