serenity::model::guild

Struct Emoji

Source
#[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.

Discord docs.

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§

Source§

impl Emoji

Source

pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()>

👎Deprecated: Use Guild(Id)::delete_emoji, this performs a loop over all guilds!
Available on crate features model and cache only.

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

Note: If the emoji was created by the current user, requires either the Create Guild Expressions or the Manage Guild Expressions permission. Otherwise, the Manage Guild Expressions 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.

Source

pub async fn edit( &mut self, cache_http: impl CacheHttp, name: &str, ) -> Result<()>

👎Deprecated: Use Guild(Id)::edit_emoji, this performs a loop over all guilds!
Available on crate features model and cache only.

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

Note: If the emoji was created by the current user, requires either the Create Guild Expressions or the Manage Guild Expressions permission. Otherwise, the Manage Guild Expressions permission is required.

§Errors

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

Source

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

👎Deprecated: This performs a loop over all guilds and should not be used.
Available on crate features model and cache only.

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) {
    println!("{} is owned by {}", emoji.name, guild_id);
}
Source

pub fn url(&self) -> String

Available on crate feature model only.

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§

Source§

impl ArgumentConvert for Emoji

Available on crate features client and utils only.

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.
Source§

type Err = EmojiParseError

The associated error which can be returned from parsing.
Source§

fn convert<'life0, 'async_trait>( ctx: impl 'async_trait + CacheHttp, guild_id: Option<GuildId>, _channel_id: Option<ChannelId>, s: &'life0 str, ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

impl Clone for Emoji

Source§

fn clone(&self) -> Emoji

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 Emoji

Source§

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

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

impl<'de> Deserialize<'de> for Emoji

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Emoji

Source§

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

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.

Source§

impl From<&Emoji> for EmojiId

Source§

fn from(emoji: &Emoji) -> EmojiId

Gets the Id of an Emoji.

Source§

impl From<Emoji> for EmojiId

Source§

fn from(emoji: Emoji) -> EmojiId

Gets the Id of an Emoji.

Source§

impl From<Emoji> for ReactionType

Source§

fn from(emoji: Emoji) -> ReactionType

Converts to this type from the input type.
Source§

impl Serialize for Emoji

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§

§

impl Freeze for Emoji

§

impl RefUnwindSafe for Emoji

§

impl Send for Emoji

§

impl Sync for Emoji

§

impl Unpin for Emoji

§

impl UnwindSafe for Emoji

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
§

impl<T> CloneDebuggableStorage for T
where T: DebuggableStorage + Clone,

§

fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

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

§

fn clone_storage(&self) -> Box<dyn CloneableStorage>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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

Source§

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

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

Source§

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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T