[commands] Add ForumChannelConverter converter

This commit is contained in:
Rapptz
2022-04-13 17:44:03 -04:00
parent d98ee567d4
commit 141d9f4c71
2 changed files with 23 additions and 0 deletions

View File

@ -74,6 +74,7 @@ __all__ = (
'EmojiConverter',
'PartialEmojiConverter',
'CategoryChannelConverter',
'ForumChannelConverter',
'IDConverter',
'ThreadConverter',
'GuildChannelConverter',
@ -580,6 +581,25 @@ class ThreadConverter(IDConverter[discord.Thread]):
return GuildChannelConverter._resolve_thread(ctx, argument, 'threads', discord.Thread)
class ForumChannelConverter(IDConverter[discord.ForumChannel]):
"""Converts to a :class:`~discord.ForumChannel`.
All lookups are via the local guild. If in a DM context, then the lookup
is done by the global cache.
The lookup strategy is as follows (in order):
1. Lookup by ID.
2. Lookup by mention.
3. Lookup by name
.. versionadded:: 2.0
"""
async def convert(self, ctx: Context[BotT], argument: str) -> discord.ForumChannel:
return GuildChannelConverter._resolve_channel(ctx, argument, 'forums', discord.ForumChannel)
class ColourConverter(Converter[discord.Colour]):
"""Converts to a :class:`~discord.Colour`.