channel¶
Useful helper functions for interacting with various discord channel objects.
- async get_or_fetch_channel(bot, channel_id)[source]¶
Attempt to get or fetch the given
channel_id
from the bots cache, and return it.- Parameters:
bot (
Bot
) – Thediscord.ext.commands.Bot
instance to use for getting/fetching.channel_id (
int
) – The channel to get/fetch.
- Raises:
discord.InvalidData – An unknown channel type was received from Discord.
discord.HTTPException – Retrieving the channel failed.
discord.NotFound – Invalid Channel ID.
discord.Forbidden – You do not have permission to fetch this channel.
- Return type:
- Returns:
The channel from the ID.
- is_in_category(channel, category_id)[source]¶
Return whether the given
channel
in the the category with the idcategory_id
.- Parameters:
channel (
TextChannel
) – The channel to check.category_id (
int
) – The category to check for.
- Return type:
- Returns:
A bool depending on whether the channel is in the category.