glyde/emoji

Two shapes. Emoji is the partial a button, a select option and a reaction carry; GuildEmoji is a guild’s own upload, where id and name are always present.

Types

The id and the name move together. A unicode emoji is its name and has no id; a custom one is its id and may have lost its name. Discord never sends neither, and only a custom emoji is ever animated.

pub type Emoji {
  Unicode(name: String)
  Custom(
    id: id.Id(id.Emoji),
    name: option.Option(String),
    animated: Bool,
  )
}

Constructors

  • Unicode(name: String)
  • Custom(
      id: id.Id(id.Emoji),
      name: option.Option(String),
      animated: Bool,
    )

    name is null in reactions, for a custom emoji deleted since.

A guild’s own emoji, from Guild.emojis and GUILD_EMOJIS_UPDATE. Always custom, always named; the roles and uploader are never on a component or a reaction. Use as_partial to send one.

pub type GuildEmoji {
  GuildEmoji(
    id: id.Id(id.Emoji),
    name: String,
    animated: Bool,
    roles: List(id.Id(id.Role)),
    uploader: option.Option(user.User),
    require_colons: Bool,
    managed: Bool,
    available: Bool,
  )
}

Constructors

  • GuildEmoji(
      id: id.Id(id.Emoji),
      name: String,
      animated: Bool,
      roles: List(id.Id(id.Role)),
      uploader: option.Option(user.User),
      require_colons: Bool,
      managed: Bool,
      available: Bool,
    )

    Arguments

    roles

    The roles allowed to use it.

    uploader

    Who uploaded it. Needs the MANAGE_GUILD_EXPRESSIONS permission.

    available

    False when the guild lost the boosts that paid for it.

Values

pub fn animated_custom(
  id: id.Id(id.Emoji),
  name: String,
) -> Emoji

A custom emoji whose frames Discord plays.

pub fn as_partial(full: GuildEmoji) -> Emoji

The partial shape for reacting with, or putting on a button.

pub fn custom(id: id.Id(id.Emoji), name: String) -> Emoji

The partial that reactions and components take. For an animated one, use animated_custom.

pub fn decoder() -> decode.Decoder(Emoji)
pub fn guild_emoji_decoder() -> decode.Decoder(GuildEmoji)

The id and name are required here. A guild’s own list never carries a unicode or a nameless entry, so a payload without them fails to decode.

pub fn to_json(emoji: Emoji) -> json.Json

The partial Discord accepts in a component or a reaction. A null id is how it tells a unicode emoji from a custom one, so the key is always there.

pub fn unicode(name: String) -> Emoji

A standard emoji, named by the character itself.

Search Document