Skip to content

Commit f6e0f72

Browse files
authored
Add ability to create a media-only forum channel
1 parent 4862ea2 commit f6e0f72

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

discord/guild.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ async def create_forum(
18001800
category: Optional[CategoryChannel] = None,
18011801
slowmode_delay: int = MISSING,
18021802
nsfw: bool = MISSING,
1803+
media: bool = MISSING,
18031804
overwrites: Mapping[Union[Role, Member, Object], PermissionOverwrite] = MISSING,
18041805
reason: Optional[str] = None,
18051806
default_auto_archive_duration: int = MISSING,
@@ -1862,12 +1863,17 @@ async def create_forum(
18621863
.. versionadded:: 2.3
18631864
default_layout: :class:`ForumLayoutType`
18641865
The default layout for posts in this forum.
1866+
This cannot be set if ``media`` is set to ``True``.
18651867
18661868
.. versionadded:: 2.3
18671869
available_tags: Sequence[:class:`ForumTag`]
18681870
The available tags for this forum channel.
18691871
18701872
.. versionadded:: 2.1
1873+
media: :class:`bool`
1874+
Whether to create a media forum channel.
1875+
1876+
.. versionadded:: 2.6
18711877
18721878
Raises
18731879
-------
@@ -1919,7 +1925,7 @@ async def create_forum(
19191925
else:
19201926
raise ValueError(f'default_reaction_emoji parameter must be either Emoji, PartialEmoji, or str')
19211927

1922-
if default_layout is not MISSING:
1928+
if not media and default_layout is not MISSING:
19231929
if not isinstance(default_layout, ForumLayoutType):
19241930
raise TypeError(
19251931
f'default_layout parameter must be a ForumLayoutType not {default_layout.__class__.__name__}'
@@ -1931,10 +1937,17 @@ async def create_forum(
19311937
options['available_tags'] = [t.to_dict() for t in available_tags]
19321938

19331939
data = await self._create_channel(
1934-
name=name, overwrites=overwrites, channel_type=ChannelType.forum, category=category, reason=reason, **options
1940+
name=name,
1941+
overwrites=overwrites,
1942+
channel_type=ChannelType.forum if not media else ChannelType.media,
1943+
category=category,
1944+
reason=reason,
1945+
**options,
19351946
)
19361947

1937-
channel = ForumChannel(state=self._state, guild=self, data=data)
1948+
channel = ForumChannel(
1949+
state=self._state, guild=self, data=data # pyright: ignore[reportArgumentType] # it's the correct data
1950+
)
19381951

19391952
# temporarily add to the cache
19401953
self._channels[channel.id] = channel

0 commit comments

Comments
 (0)