aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-07-29 01:21:48 -0400
committerRapptz <[email protected]>2021-07-29 01:22:07 -0400
commit0d3bd3083c2b3bb74f3d8ae30063a033f3652730 (patch)
tree843229f947f931f1fa6c38abf3f4b76381be67f1
parent[commands] Check for ctx.guild instead of abc.GuildChannel (diff)
downloaddiscord.py-0d3bd3083c2b3bb74f3d8ae30063a033f3652730.tar.xz
discord.py-0d3bd3083c2b3bb74f3d8ae30063a033f3652730.zip
Add Guild.get_channel_or_thread helper method
The name might change in the future, unsure.
-rw-r--r--discord/guild.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 6e8aa711..c65296db 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -599,6 +599,24 @@ class Guild(Hashable):
return self._channels.get(id) or self._threads.get(id)
+ def get_channel_or_thread(self, channel_id: int, /) -> Optional[Union[Thread, GuildChannel]]:
+ """Returns a channel or thread with the given ID.
+
+ .. versionadded:: 2.0
+
+ Parameters
+ -----------
+ channel_id: :class:`int`
+ The ID to search for.
+
+ Returns
+ --------
+ Optional[Union[:class:`Thread`, :class:`.abc.GuildChannel`]]
+ The returned channel or thread or ``None`` if not found.
+ """
+ return self._channels.get(channel_id) or self._threads.get(channel_id)
+
+
def get_channel(self, channel_id: int, /) -> Optional[GuildChannel]:
"""Returns a channel with the given ID.