From 198425707e4bc61939a37eeab6d40b7ea2e1e949 Mon Sep 17 00:00:00 2001 From: rdrescher909 <51489753+rdrescher909@users.noreply.github.com> Date: Sun, 12 Mar 2023 22:13:08 -0400 Subject: [PATCH] Add Guild.get_emoji helper --- discord/guild.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/discord/guild.py b/discord/guild.py index f80429173..596c6865c 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -737,6 +737,26 @@ class Guild(Hashable): """ 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 def system_channel(self) -> Optional[TextChannel]: """Optional[:class:`TextChannel`]: Returns the guild's channel used for system messages.