|
|
@ -98,6 +98,7 @@ if TYPE_CHECKING: |
|
|
|
CategoryChannel as CategoryChannelPayload, |
|
|
|
GroupDMChannel as GroupChannelPayload, |
|
|
|
ForumChannel as ForumChannelPayload, |
|
|
|
MediaChannel as MediaChannelPayload, |
|
|
|
ForumTag as ForumTagPayload, |
|
|
|
) |
|
|
|
from .types.snowflake import SnowflakeList |
|
|
@ -2202,6 +2203,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): |
|
|
|
'topic', |
|
|
|
'_state', |
|
|
|
'_flags', |
|
|
|
'_type', |
|
|
|
'nsfw', |
|
|
|
'category_id', |
|
|
|
'position', |
|
|
@ -2217,9 +2219,10 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): |
|
|
|
'_flags', |
|
|
|
) |
|
|
|
|
|
|
|
def __init__(self, *, state: ConnectionState, guild: Guild, data: ForumChannelPayload): |
|
|
|
def __init__(self, *, state: ConnectionState, guild: Guild, data: Union[ForumChannelPayload, MediaChannelPayload]): |
|
|
|
self._state: ConnectionState = state |
|
|
|
self.id: int = int(data['id']) |
|
|
|
self._type: Literal[15, 16] = data['type'] |
|
|
|
self._update(guild, data) |
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
@ -2233,7 +2236,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): |
|
|
|
joined = ' '.join('%s=%r' % t for t in attrs) |
|
|
|
return f'<{self.__class__.__name__} {joined}>' |
|
|
|
|
|
|
|
def _update(self, guild: Guild, data: ForumChannelPayload) -> None: |
|
|
|
def _update(self, guild: Guild, data: Union[ForumChannelPayload, MediaChannelPayload]) -> None: |
|
|
|
self.guild: Guild = guild |
|
|
|
self.name: str = data['name'] |
|
|
|
self.category_id: Optional[int] = utils._get_as_snowflake(data, 'parent_id') |
|
|
@ -2267,8 +2270,10 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): |
|
|
|
self._fill_overwrites(data) |
|
|
|
|
|
|
|
@property |
|
|
|
def type(self) -> Literal[ChannelType.forum]: |
|
|
|
def type(self) -> Literal[ChannelType.forum, ChannelType.media]: |
|
|
|
""":class:`ChannelType`: The channel's Discord type.""" |
|
|
|
if self._type == 16: |
|
|
|
return ChannelType.media |
|
|
|
return ChannelType.forum |
|
|
|
|
|
|
|
@property |
|
|
@ -2356,6 +2361,13 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): |
|
|
|
""":class:`bool`: Checks if the forum is NSFW.""" |
|
|
|
return self.nsfw |
|
|
|
|
|
|
|
def is_media(self) -> bool: |
|
|
|
""":class:`bool`: Checks if the channel is a media channel. |
|
|
|
|
|
|
|
.. versionadded:: 2.4 |
|
|
|
""" |
|
|
|
return self._type == ChannelType.media.value |
|
|
|
|
|
|
|
@utils.copy_doc(discord.abc.GuildChannel.clone) |
|
|
|
async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = None) -> ForumChannel: |
|
|
|
return await self._clone_impl( |
|
|
@ -3314,6 +3326,8 @@ def _guild_channel_factory(channel_type: int): |
|
|
|
return StageChannel, value |
|
|
|
elif value is ChannelType.forum: |
|
|
|
return ForumChannel, value |
|
|
|
elif value is ChannelType.media: |
|
|
|
return ForumChannel, value |
|
|
|
else: |
|
|
|
return None, value |
|
|
|
|
|
|
|