Browse Source

[commands] Add ForumChannelConverter converter

pull/7888/head
Rapptz 3 years ago
parent
commit
141d9f4c71
  1. 20
      discord/ext/commands/converter.py
  2. 3
      docs/ext/commands/commands.rst

20
discord/ext/commands/converter.py

@ -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`.

3
docs/ext/commands/commands.rst

@ -391,6 +391,7 @@ A lot of discord models work out of the gate as a parameter:
- :class:`VoiceChannel`
- :class:`StageChannel` (since v1.7)
- :class:`CategoryChannel`
- :class:`ForumChannel` (since v2.0)
- :class:`Invite`
- :class:`Guild` (since v1.7)
- :class:`Role`
@ -431,6 +432,8 @@ converter is given below:
+--------------------------+-------------------------------------------------+
| :class:`CategoryChannel` | :class:`~ext.commands.CategoryChannelConverter` |
+--------------------------+-------------------------------------------------+
| :class:`ForumChannel` | :class:`~ext.commands.ForumChannelConverter` |
+--------------------------+-------------------------------------------------+
| :class:`Invite` | :class:`~ext.commands.InviteConverter` |
+--------------------------+-------------------------------------------------+
| :class:`Guild` | :class:`~ext.commands.GuildConverter` |

Loading…
Cancel
Save