mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-01 15:50:02 +00:00
Add ability to create a media-only forum channel
This commit is contained in:
parent
4862ea22fd
commit
f6e0f72498
@ -1800,6 +1800,7 @@ class Guild(Hashable):
|
|||||||
category: Optional[CategoryChannel] = None,
|
category: Optional[CategoryChannel] = None,
|
||||||
slowmode_delay: int = MISSING,
|
slowmode_delay: int = MISSING,
|
||||||
nsfw: bool = MISSING,
|
nsfw: bool = MISSING,
|
||||||
|
media: bool = MISSING,
|
||||||
overwrites: Mapping[Union[Role, Member, Object], PermissionOverwrite] = MISSING,
|
overwrites: Mapping[Union[Role, Member, Object], PermissionOverwrite] = MISSING,
|
||||||
reason: Optional[str] = None,
|
reason: Optional[str] = None,
|
||||||
default_auto_archive_duration: int = MISSING,
|
default_auto_archive_duration: int = MISSING,
|
||||||
@ -1862,12 +1863,17 @@ class Guild(Hashable):
|
|||||||
.. versionadded:: 2.3
|
.. versionadded:: 2.3
|
||||||
default_layout: :class:`ForumLayoutType`
|
default_layout: :class:`ForumLayoutType`
|
||||||
The default layout for posts in this forum.
|
The default layout for posts in this forum.
|
||||||
|
This cannot be set if ``media`` is set to ``True``.
|
||||||
|
|
||||||
.. versionadded:: 2.3
|
.. versionadded:: 2.3
|
||||||
available_tags: Sequence[:class:`ForumTag`]
|
available_tags: Sequence[:class:`ForumTag`]
|
||||||
The available tags for this forum channel.
|
The available tags for this forum channel.
|
||||||
|
|
||||||
.. versionadded:: 2.1
|
.. versionadded:: 2.1
|
||||||
|
media: :class:`bool`
|
||||||
|
Whether to create a media forum channel.
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -1919,7 +1925,7 @@ class Guild(Hashable):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(f'default_reaction_emoji parameter must be either Emoji, PartialEmoji, or str')
|
raise ValueError(f'default_reaction_emoji parameter must be either Emoji, PartialEmoji, or str')
|
||||||
|
|
||||||
if default_layout is not MISSING:
|
if not media and default_layout is not MISSING:
|
||||||
if not isinstance(default_layout, ForumLayoutType):
|
if not isinstance(default_layout, ForumLayoutType):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'default_layout parameter must be a ForumLayoutType not {default_layout.__class__.__name__}'
|
f'default_layout parameter must be a ForumLayoutType not {default_layout.__class__.__name__}'
|
||||||
@ -1931,10 +1937,17 @@ class Guild(Hashable):
|
|||||||
options['available_tags'] = [t.to_dict() for t in available_tags]
|
options['available_tags'] = [t.to_dict() for t in available_tags]
|
||||||
|
|
||||||
data = await self._create_channel(
|
data = await self._create_channel(
|
||||||
name=name, overwrites=overwrites, channel_type=ChannelType.forum, category=category, reason=reason, **options
|
name=name,
|
||||||
|
overwrites=overwrites,
|
||||||
|
channel_type=ChannelType.forum if not media else ChannelType.media,
|
||||||
|
category=category,
|
||||||
|
reason=reason,
|
||||||
|
**options,
|
||||||
)
|
)
|
||||||
|
|
||||||
channel = ForumChannel(state=self._state, guild=self, data=data)
|
channel = ForumChannel(
|
||||||
|
state=self._state, guild=self, data=data # pyright: ignore[reportArgumentType] # it's the correct data
|
||||||
|
)
|
||||||
|
|
||||||
# temporarily add to the cache
|
# temporarily add to the cache
|
||||||
self._channels[channel.id] = channel
|
self._channels[channel.id] = channel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user