diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index c40aaef90a..69a452b6b6 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -563,6 +563,25 @@ async def convert(self, ctx: Context, argument: str) -> discord.CategoryChannel: return GuildChannelConverter._resolve_channel(ctx, argument, "categories", discord.CategoryChannel) +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, argument: str) -> discord.ForumChannel: + return GuildChannelConverter._resolve_channel(ctx, argument, "forum_channels", discord.ForumChannel) + + class ThreadConverter(IDConverter[discord.Thread]): """Coverts to a :class:`~discord.Thread`. @@ -1043,6 +1062,7 @@ def is_generic_type(tp: Any, *, _GenericAlias: Type = _GenericAlias) -> bool: discord.Emoji: EmojiConverter, discord.PartialEmoji: PartialEmojiConverter, discord.CategoryChannel: CategoryChannelConverter, + discord.ForumChannel: ForumChannelConverter, discord.Thread: ThreadConverter, discord.abc.GuildChannel: GuildChannelConverter, discord.GuildSticker: GuildStickerConverter, diff --git a/docs/ext/commands/api.rst b/docs/ext/commands/api.rst index 490dbd3a01..8d3b4f7c24 100644 --- a/docs/ext/commands/api.rst +++ b/docs/ext/commands/api.rst @@ -397,6 +397,9 @@ Converters .. autoclass:: discord.ext.commands.CategoryChannelConverter :members: +.. autoclass:: discord.ext.commands.ForumChannelConverter + :members: + .. autoclass:: discord.ext.commands.InviteConverter :members: