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 1 commit
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
15 changes: 13 additions & 2 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,7 @@
category: Optional[CategoryChannel] = None,
slowmode_delay: int = MISSING,
nsfw: bool = MISSING,
media_only: 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 @@
.. 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_only: :class:`bool`
Whether to create a media-only forum channel.

.. versionadded:: 2.6

Raises
-------
Expand Down Expand Up @@ -1919,7 +1925,7 @@
else:
raise ValueError(f'default_reaction_emoji parameter must be either Emoji, PartialEmoji, or str')

if default_layout is not MISSING:
if not media_only 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 @@
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_only else ChannelType.media,
category=category,
reason=reason,
**options,
)

channel = ForumChannel(state=self._state, guild=self, data=data)

Check failure on line 1948 in discord/guild.py

View workflow job for this annotation

GitHub Actions / check 3.x

Argument of type "GuildChannel" cannot be assigned to parameter "data" of type "ForumChannel | MediaChannel" in function "__init__"   Type "GuildChannel" is not assignable to type "ForumChannel | MediaChannel"     Type "CategoryChannel" is not assignable to type "ForumChannel | MediaChannel"       "topic" is missing from "CategoryChannel"       "last_message_id" is missing from "CategoryChannel"       "last_pin_timestamp" is missing from "CategoryChannel"       "rate_limit_per_user" is missing from "CategoryChannel"       "default_thread_rate_limit_per_user" is missing from "CategoryChannel"       "default_auto_archive_duration" is missing from "CategoryChannel" ... (reportArgumentType)

# temporarily add to the cache
self._channels[channel.id] = channel
Expand Down
Loading