Emoji¶
This section documents everything related to Discord emoji.
Discord Models¶
Emoji¶
- class disnake.Emoji[source]¶
- Represents a custom emoji. - Depending on the way this object was created, some of the attributes can have a value of - None.- x == y
- Checks if two emoji are the same. 
 - x != y
- Checks if two emoji are not the same. 
 - hash(x)
- Return the emoji’s hash. 
 - iter(x)
- Returns an iterator of - (field, value)pairs. This allows this class to be used as an iterable in list/dict/etc constructions.
 - str(x)
- Returns the emoji rendered for Discord. 
 - Changed in version 2.12.0a: This class can now represent app emojis. Use - Emoji.is_app_emojito check for this. To check if this is a guild emoji, use- Emoji.is_guild_emoji.- require_colons¶
- Whether colons are required to use this emoji in the client (:PJSalt: vs PJSalt). - Type:
 
 - user¶
- The user that created this emoji. If this is a guild emoji, this can only be retrieved using - Guild.fetch_emoji()/- Guild.fetch_emojis()while having the- manage_guild_expressionspermission.- If this is an app emoji, this is the team member that uploaded the emoji, or the bot user if created using - Client.create_application_emoji().- Type:
- Optional[ - User]
 
 - property roles[source]¶
- A - listof roles that are allowed to use this emoji.- If roles is empty, the emoji is unrestricted. - Emojis with - subscription rolesare considered premium emojis, and count towards a separate limit of 25 emojis.- Type:
- List[ - Role]
 
 - property guild[source]¶
- The guild this emoji belongs to. - Noneif this is an app emoji.- Changed in version 2.12.0a: This can now return - Noneif the emoji is an application owned emoji.- Type:
- Optional[ - Guild]
 
 - property application_id[source]¶
- The ID of the application which owns this emoji, if this is an app emoji. - New in version 2.12.0a. - Type:
- Optional[ - int]
 
 - property is_app_emoji[source]¶
- Whether this emoji is an application emoji. - New in version 2.12.0a. - Type:
 
 - await delete(*, reason=None)[source]¶
- This function is a coroutine. - Deletes the emoji. - If this is not an app emoji, you must have - manage_guild_expressionspermission to do this.- Parameters:
- reason (Optional[ - str]) –- The reason for deleting this emoji. Shows up on the audit log. - Only applies to emojis that belong to a - Guild.
- Raises:
- Forbidden – You are not allowed to delete this emoji. 
- HTTPException – An error occurred deleting the emoji. 
- InvalidData – The emoji data is invalid and cannot be processed. 
 
 
 - await edit(*, name=..., roles=..., reason=None)[source]¶
- This function is a coroutine. - Edits the emoji. - If this emoji is a guild emoji, you must have - manage_guild_expressionspermission to do this.- Changed in version 2.0: The newly updated emoji is returned. - Parameters:
- name ( - str) – The new emoji name.
- roles (Optional[List[ - Snowflake]]) –- A list of roles that can use this emoji. An empty list can be passed to make it available to everyone. - An emoji cannot have both subscription roles (see - RoleTags.integration_id) and non-subscription roles, and emojis can’t be converted between premium and non-premium after creation.- Only applies to emojis that belong to a - Guild.
- reason (Optional[ - str]) –- The reason for editing this emoji. Shows up on the audit log. - Only applies to emojis that belong to a - Guild.
 
- Raises:
- Forbidden – You are not allowed to edit this emoji. 
- HTTPException – An error occurred editing the emoji. 
- InvalidData – The emoji data is invalid and cannot be processed. 
 
- Returns:
- The newly updated emoji. 
- Return type:
 
 - await read()[source]¶
- This function is a coroutine. - Retrieves the content of this asset as a - bytesobject.- Raises:
- DiscordException – There was no internal connection state. 
- HTTPException – Downloading the asset failed. 
- NotFound – The asset was deleted. 
 
- Returns:
- The content of the asset. 
- Return type:
 
 - await save(fp, *, seek_begin=True)[source]¶
- This function is a coroutine. - Saves this asset into a file-like object. - Parameters:
- fp (Union[ - io.BufferedIOBase,- os.PathLike]) – The file-like object to save this asset to or the filename to use. If a filename is passed then a file is created with that filename and used instead.
- seek_begin ( - bool) – Whether to seek to the beginning of the file after saving is successfully done.
 
- Raises:
- DiscordException – There was no internal connection state. 
- HTTPException – Downloading the asset failed. 
- NotFound – The asset was deleted. 
 
- Returns:
- The number of bytes written. 
- Return type:
 
 - await to_file(*, spoiler=False, filename=None, description=None)[source]¶
- This function is a coroutine. - Converts the asset into a - Filesuitable for sending via- abc.Messageable.send().- New in version 2.5. - Changed in version 2.6: Raises - TypeErrorinstead of- InvalidArgument.- Parameters:
- Raises:
- DiscordException – The asset does not have an associated state. 
- HTTPException – Downloading the asset failed. 
- NotFound – The asset was deleted. 
- TypeError – The asset is a unicode emoji or a sticker with lottie type. 
 
- Returns:
- The asset as a file suitable for sending. 
- Return type:
 
 
Data Classes¶
PartialEmoji¶
- clsPartialEmoji.from_str
- defis_custom_emoji
- defis_unicode_emoji
- asyncread
- asyncsave
- asyncto_file
- class disnake.PartialEmoji(*, name, animated=False, id=None)[source]¶
- Represents a “partial” emoji. - This model will be given in two scenarios: - “Raw” data events such as - on_raw_reaction_add()
- Custom emoji that the bot cannot see from e.g. - Message.reactions
 - x == y
- Checks if two emoji are the same. 
 - x != y
- Checks if two emoji are not the same. 
 - hash(x)
- Return the emoji’s hash. 
 - str(x)
- Returns the emoji rendered for Discord. 
 - name¶
- The custom emoji name, if applicable, or the unicode codepoint of the non-custom emoji. This can be - Noneif the emoji got deleted (e.g. removing a reaction with a deleted emoji).- Type:
- Optional[ - str]
 
 - classmethod from_str(value)[source]¶
- Converts a Discord string representation of an emoji to a - PartialEmoji.- The formats accepted are: - a:name:id
- <a:name:id>
- name:id
- <:name:id>
 - If the format does not match then it is assumed to be a unicode emoji. - New in version 2.0. - Parameters:
- value ( - str) – The string representation of an emoji.
- Returns:
- The partial emoji from this string. 
- Return type:
 
 - property created_at[source]¶
- Returns the emoji’s creation time in UTC, or None if it’s a Unicode emoji. - New in version 1.6. - Type:
- Optional[ - datetime.datetime]
 
 - property url[source]¶
- Returns the URL of the emoji, if it is custom. - If this isn’t a custom emoji then an empty string is returned - Type:
 
 - await read()[source]¶
- This function is a coroutine. - Retrieves the data of this emoji as a - bytesobject.- Changed in version 2.6: Raises - TypeErrorinstead of- InvalidArgument.- Raises:
- TypeError – The emoji is not a custom emoji. 
- DiscordException – There was no internal connection state. 
- HTTPException – Downloading the asset failed. 
- NotFound – The asset was deleted. 
 
- Returns:
- The content of the asset. 
- Return type:
 
 - await save(fp, *, seek_begin=True)[source]¶
- This function is a coroutine. - Saves this asset into a file-like object. - Parameters:
- fp (Union[ - io.BufferedIOBase,- os.PathLike]) – The file-like object to save this asset to or the filename to use. If a filename is passed then a file is created with that filename and used instead.
- seek_begin ( - bool) – Whether to seek to the beginning of the file after saving is successfully done.
 
- Raises:
- DiscordException – There was no internal connection state. 
- HTTPException – Downloading the asset failed. 
- NotFound – The asset was deleted. 
 
- Returns:
- The number of bytes written. 
- Return type:
 
 - await to_file(*, spoiler=False, filename=None, description=None)[source]¶
- This function is a coroutine. - Converts the asset into a - Filesuitable for sending via- abc.Messageable.send().- New in version 2.5. - Changed in version 2.6: Raises - TypeErrorinstead of- InvalidArgument.- Parameters:
- Raises:
- DiscordException – The asset does not have an associated state. 
- HTTPException – Downloading the asset failed. 
- NotFound – The asset was deleted. 
- TypeError – The asset is a unicode emoji or a sticker with lottie type. 
 
- Returns:
- The asset as a file suitable for sending. 
- Return type: