Add support for discord.abc.GuildChannel annotations in app commands

This commit is contained in:
Rapptz 2022-06-11 20:36:15 -04:00
parent d19faa5f32
commit 334ef1d7fa

View File

@ -47,6 +47,7 @@ from typing import (
from .errors import AppCommandError, TransformerError from .errors import AppCommandError, TransformerError
from .models import AppCommandChannel, AppCommandThread, Choice from .models import AppCommandChannel, AppCommandThread, Choice
from ..channel import StageChannel, VoiceChannel, TextChannel, CategoryChannel from ..channel import StageChannel, VoiceChannel, TextChannel, CategoryChannel
from ..abc import GuildChannel
from ..threads import Thread from ..threads import Thread
from ..enums import Enum as InternalEnum, AppCommandOptionType, ChannelType from ..enums import Enum as InternalEnum, AppCommandOptionType, ChannelType
from ..utils import MISSING, maybe_coroutine from ..utils import MISSING, maybe_coroutine
@ -574,6 +575,13 @@ CHANNEL_TO_TYPES: Dict[Any, List[ChannelType]] = {
ChannelType.news, ChannelType.news,
ChannelType.category, ChannelType.category,
], ],
GuildChannel: [
ChannelType.stage_voice,
ChannelType.voice,
ChannelType.text,
ChannelType.news,
ChannelType.category,
],
AppCommandThread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread], AppCommandThread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread],
Thread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread], Thread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread],
StageChannel: [ChannelType.stage_voice], StageChannel: [ChannelType.stage_voice],
@ -592,6 +600,7 @@ BUILT_IN_TRANSFORMERS: Dict[Any, Type[Transformer]] = {
Role: passthrough_transformer(AppCommandOptionType.role), Role: passthrough_transformer(AppCommandOptionType.role),
AppCommandChannel: channel_transformer(AppCommandChannel, raw=True), AppCommandChannel: channel_transformer(AppCommandChannel, raw=True),
AppCommandThread: channel_transformer(AppCommandThread, raw=True), AppCommandThread: channel_transformer(AppCommandThread, raw=True),
GuildChannel: channel_transformer(GuildChannel),
Thread: channel_transformer(Thread), Thread: channel_transformer(Thread),
StageChannel: channel_transformer(StageChannel), StageChannel: channel_transformer(StageChannel),
VoiceChannel: channel_transformer(VoiceChannel), VoiceChannel: channel_transformer(VoiceChannel),