Emoji

discord_http.emoji module

class discord_http.emoji.Emoji(*, state, data, guild=None)

Bases: PartialEmoji

Represents a Discord emoji.

Parameters:
property created_at: datetime

The datetime of the snowflake.

async delete(*, reason=None) None

Deletes the emoji.

If guild_id is not defined, it will delete the emoji from the application.

Parameters:

reason (str | None) – The reason for deleting the emoji.

Return type:

None

async edit(*, name=<MISSING>, roles=<MISSING>, reason=None) Emoji

Edits the emoji.

Parameters:
  • name (str | None) – The new name of the emoji.

  • roles (list[PartialRole | int] | None) – Roles that are allowed to use the emoji. (Only for guilds)

  • reason (str | None) – The reason for editing the emoji. (Only for guilds)

Return type:

Emoji

Returns:

The edited emoji.

Raises:

ValueError – Whenever guild_id is not defined

async fetch() Emoji

Emoji: Fetches the emoji.

If guild_id is not defined, it will fetch the emoji from the application.

Return type:

Emoji

property guild: Guild | PartialGuild | None

The guild of the member.

guild_id: int | None

The ID of the guild the emoji belongs to, if any.

id: int

The ID of the snowflake.

name: str

The name of the emoji.

animated: bool

Whether the emoji is animated or not.

available: bool

Whether the emoji is available or not.

require_colons: bool

Whether the emoji requires colons or not.

managed: bool

Whether the emoji is managed by an integration or not.

user: User | None

The user that created the emoji, if available.

roles: list[PartialRole]

The roles that are allowed to use the emoji. (Only for guilds).

property url: str

Returns the URL of the emoji.

class discord_http.emoji.EmojiParser(emoji)

Bases: object

Used to accept any input and convert to either a normal emoji or a Discord emoji automatically.

It is used for things like reactions, forum, components, etc

Examples

  • EmojiParser(”👍”)

  • EmojiParser(“<:name:1234567890>”)

  • EmojiParser(“1234567890”)

Parameters:

emoji (str)

raw: str

The raw emoji string that was passed to the constructor.

animated: bool

Whether the emoji is animated or not.

discord_emoji: bool

Whether the emoji is a Discord emoji or not.

id: int | None

The ID of the emoji if it’s a Discord emoji, otherwise None.

name: str

The name of the emoji. If it’s a Discord emoji, it will be the name of the emoji.

classmethod from_dict(data) Self

Create an emoji from a dictionary.

Parameters:

data (dict) – The dictionary to create the emoji from

Return type:

Self

Returns:

The emoji

property url: str | None

Returns the URL of the emoji if it’s a Discord emoji.

to_dict() dict

Returns a dict representation of the emoji.

Return type:

dict

to_forum_dict() dict

Returns a dict representation of emoji to forum/media channel.

Return type:

dict

to_reaction() str

Returns a string representation of the emoji.

Return type:

str

class discord_http.emoji.PartialEmoji(*, state, id, guild_id=None)

Bases: PartialBase

Represents a partial emoji.

This is used when the emoji is not fully available, such as in reactions.

Parameters:
guild_id: int | None

The ID of the guild the emoji belongs to, if any.

property guild: Guild | PartialGuild | None

The guild of the member.

property url: str

Returns the URL of the emoji.

It will always be PNG as it’s a partial emoji.

Type:

str

async fetch() Emoji

Emoji: Fetches the emoji.

If guild_id is not defined, it will fetch the emoji from the application.

Return type:

Emoji

async delete(*, reason=None) None

Deletes the emoji.

If guild_id is not defined, it will delete the emoji from the application.

Parameters:

reason (str | None) – The reason for deleting the emoji.

Return type:

None

async edit(*, name=<MISSING>, roles=<MISSING>, reason=None) Emoji

Edits the emoji.

Parameters:
  • name (str | None) – The new name of the emoji.

  • roles (list[PartialRole | int] | None) – Roles that are allowed to use the emoji. (Only for guilds)

  • reason (str | None) – The reason for editing the emoji. (Only for guilds)

Return type:

Emoji

Returns:

The edited emoji.

Raises:

ValueError – Whenever guild_id is not defined

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.