Skip to content

Add ability to create a media-only forum channel #10170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,7 @@ async def create_forum(
category: Optional[CategoryChannel] = None,
slowmode_delay: int = MISSING,
nsfw: bool = MISSING,
media: bool = MISSING,
overwrites: Mapping[Union[Role, Member, Object], PermissionOverwrite] = MISSING,
reason: Optional[str] = None,
default_auto_archive_duration: int = MISSING,
Expand Down Expand Up @@ -1862,12 +1863,17 @@ async def create_forum(
.. versionadded:: 2.3
default_layout: :class:`ForumLayoutType`
The default layout for posts in this forum.
This cannot be set if ``media_only`` is set to ``True``.

.. versionadded:: 2.3
available_tags: Sequence[:class:`ForumTag`]
The available tags for this forum channel.

.. versionadded:: 2.1
media: :class:`bool`
Whether to create a media forum channel.

.. versionadded:: 2.6

Raises
-------
Expand Down Expand Up @@ -1919,7 +1925,7 @@ async def create_forum(
else:
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):
raise TypeError(
f'default_layout parameter must be a ForumLayoutType not {default_layout.__class__.__name__}'
Expand All @@ -1931,10 +1937,15 @@ async def create_forum(
options['available_tags'] = [t.to_dict() for t in available_tags]

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
self._channels[channel.id] = channel
Expand Down
Loading