Add Guild.get_emoji helper

This commit is contained in:
rdrescher909 2023-03-12 22:13:08 -04:00 committed by GitHub
parent dc9fb1fd84
commit 198425707e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -737,6 +737,26 @@ class Guild(Hashable):
""" """
return self._threads.get(thread_id) return self._threads.get(thread_id)
def get_emoji(self, emoji_id: int, /) -> Optional[Emoji]:
"""Returns an emoji with the given ID.
.. versionadded:: 2.3
Parameters
----------
emoji_id: int
The ID to search for.
Returns
--------
Optional[:class:`Emoji`]
The returned Emoji or ``None`` if not found.
"""
emoji = self._state.get_emoji(emoji_id)
if emoji and emoji.guild == self:
return emoji
return None
@property @property
def system_channel(self) -> Optional[TextChannel]: def system_channel(self) -> Optional[TextChannel]:
"""Optional[:class:`TextChannel`]: Returns the guild's channel used for system messages. """Optional[:class:`TextChannel`]: Returns the guild's channel used for system messages.