|
29 | 29 | from typing import TYPE_CHECKING, Literal, Optional, Type, Union
|
30 | 30 |
|
31 | 31 | from ..abc import GuildChannel, Mentionable
|
32 |
| -from ..channel import CategoryChannel, StageChannel, TextChannel, Thread, VoiceChannel |
| 32 | +from ..channel import ( |
| 33 | + CategoryChannel, |
| 34 | + DMChannel, |
| 35 | + ForumChannel, |
| 36 | + StageChannel, |
| 37 | + TextChannel, |
| 38 | + Thread, |
| 39 | + VoiceChannel, |
| 40 | +) |
33 | 41 | from ..enums import ChannelType
|
34 | 42 | from ..enums import Enum as DiscordEnum
|
35 | 43 | from ..enums import SlashCommandOptionType
|
|
73 | 81 | StageChannel: ChannelType.stage_voice,
|
74 | 82 | CategoryChannel: ChannelType.category,
|
75 | 83 | Thread: ChannelType.public_thread,
|
| 84 | + ForumChannel: ChannelType.forum, |
| 85 | + DMChannel: ChannelType.private, |
76 | 86 | }
|
77 | 87 |
|
78 | 88 |
|
@@ -138,6 +148,10 @@ class Option:
|
138 | 148 | .. note::
|
139 | 149 |
|
140 | 150 | Does not validate the input value against the autocomplete results.
|
| 151 | + channel_types: list[:class:`discord.ChannelType`] | None |
| 152 | + A list of channel types that can be selected in this option. |
| 153 | + Only applies to Options with an :attr:`input_type` of :class:`discord.SlashCommandOptionType.channel`. |
| 154 | + If this argument is used, :attr:`input_type` will be ignored. |
141 | 155 | name_localizations: Optional[Dict[:class:`str`, :class:`str`]]
|
142 | 156 | The name localizations for this option. The values of this should be ``"locale": "name"``.
|
143 | 157 | See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
|
@@ -224,11 +238,12 @@ def __init__(
|
224 | 238 | self._raw_type = input_type.__args__ # type: ignore # Union.__args__
|
225 | 239 | else:
|
226 | 240 | self._raw_type = (input_type,)
|
227 |
| - self.channel_types = [ |
228 |
| - CHANNEL_TYPE_MAP[t] |
229 |
| - for t in self._raw_type |
230 |
| - if t is not GuildChannel |
231 |
| - ] |
| 241 | + if not self.channel_types: |
| 242 | + self.channel_types = [ |
| 243 | + CHANNEL_TYPE_MAP[t] |
| 244 | + for t in self._raw_type |
| 245 | + if t is not GuildChannel |
| 246 | + ] |
232 | 247 | self.required: bool = (
|
233 | 248 | kwargs.pop("required", True) if "default" not in kwargs else False
|
234 | 249 | )
|
|
0 commit comments