aboutsummaryrefslogtreecommitdiffstats
path: root/botcore/utils/channel.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-02-24 16:12:21 +0000
committerGravatar Chris Lovering <[email protected]>2022-02-24 17:32:48 +0000
commit54e3d222deb92ba89072589477114d7d9ceec382 (patch)
tree8ca8713bf2516bf770ebeb4442574105b4241117 /botcore/utils/channel.py
parentRename loggers.py to logging.py to allow for more generic utils in future (diff)
Consistently use double backticks when referring to a variable name.
Also add sphix-style docstrings to functions that were previously missing them.
Diffstat (limited to 'botcore/utils/channel.py')
-rw-r--r--botcore/utils/channel.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/botcore/utils/channel.py b/botcore/utils/channel.py
index db155911..17e70a2a 100644
--- a/botcore/utils/channel.py
+++ b/botcore/utils/channel.py
@@ -10,7 +10,7 @@ log = logging.get_logger(__name__)
def is_in_category(channel: discord.TextChannel, category_id: int) -> bool:
"""
- Return whether the given channel has the category_id.
+ Return whether the given ``channel`` in the the category with the id ``category_id``.
Args:
channel: The channel to check.
@@ -23,7 +23,26 @@ def is_in_category(channel: discord.TextChannel, category_id: int) -> bool:
async def get_or_fetch_channel(bot: Bot, channel_id: int) -> discord.abc.GuildChannel:
- """Attempt to get or fetch a channel and return it."""
+ """
+ Attempt to get or fetch the given ``channel_id`` from the bots cache, and return it.
+
+ Args:
+ bot: The :obj:`discord.ext.commands.Bot` instance to use for getting/fetching.
+ channel_id: The channel to get/fetch.
+
+ Raises:
+ :exc:`discord.InvalidData`
+ An unknown channel type was received from Discord.
+ :exc:`discord.HTTPException`
+ Retrieving the channel failed.
+ :exc:`discord.NotFound`
+ Invalid Channel ID.
+ :exc:`discord.Forbidden`
+ You do not have permission to fetch this channel.
+
+ Returns:
+ The channel from the ID.
+ """
log.trace(f"Getting the channel {channel_id}.")
channel = bot.get_channel(channel_id)