Browse Source

Fix improper usages of Optional MISSING in create_forum

pull/9301/head
Rapptz 2 years ago
parent
commit
08d668f21b
  1. 18
      discord/guild.py

18
discord/guild.py

@ -1608,9 +1608,9 @@ class Guild(Hashable):
reason: Optional[str] = None, reason: Optional[str] = None,
default_auto_archive_duration: int = MISSING, default_auto_archive_duration: int = MISSING,
default_thread_slowmode_delay: int = MISSING, default_thread_slowmode_delay: int = MISSING,
default_sort_order: Optional[ForumOrderType] = MISSING, default_sort_order: ForumOrderType = MISSING,
default_reaction_emoji: Optional[EmojiInputType] = MISSING, default_reaction_emoji: EmojiInputType = MISSING,
default_layout: Optional[ForumLayoutType] = MISSING, default_layout: ForumLayoutType = MISSING,
available_tags: Sequence[ForumTag] = MISSING, available_tags: Sequence[ForumTag] = MISSING,
) -> ForumChannel: ) -> ForumChannel:
"""|coro| """|coro|
@ -1655,16 +1655,16 @@ class Guild(Hashable):
The default slowmode delay in seconds for threads created in this forum. The default slowmode delay in seconds for threads created in this forum.
.. versionadded:: 2.1 .. versionadded:: 2.1
default_sort_order: Optional[:class:`ForumOrderType`] default_sort_order: :class:`ForumOrderType`
The default sort order for posts in this forum channel. The default sort order for posts in this forum channel.
.. versionadded:: 2.3 .. versionadded:: 2.3
default_reaction_emoji: Optional[Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`]] default_reaction_emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`]
The default reaction emoji for threads created in this forum to show in the The default reaction emoji for threads created in this forum to show in the
add reaction button. add reaction button.
.. versionadded:: 2.3 .. versionadded:: 2.3
default_layout: Optional[:class:`ForumLayoutType`] default_layout: :class:`ForumLayoutType`
The default layout for posts in this forum. The default layout for posts in this forum.
.. versionadded:: 2.3 .. versionadded:: 2.3
@ -1707,7 +1707,7 @@ class Guild(Hashable):
if default_thread_slowmode_delay is not MISSING: if default_thread_slowmode_delay is not MISSING:
options['default_thread_rate_limit_per_user'] = default_thread_slowmode_delay options['default_thread_rate_limit_per_user'] = default_thread_slowmode_delay
if default_sort_order not in (MISSING, None): if default_sort_order is not MISSING:
if not isinstance(default_sort_order, ForumOrderType): if not isinstance(default_sort_order, ForumOrderType):
raise TypeError( raise TypeError(
f'default_sort_order parameter must be a ForumOrderType not {default_sort_order.__class__.__name__}' f'default_sort_order parameter must be a ForumOrderType not {default_sort_order.__class__.__name__}'
@ -1715,7 +1715,7 @@ class Guild(Hashable):
options['default_sort_order'] = default_sort_order.value options['default_sort_order'] = default_sort_order.value
if default_reaction_emoji not in (MISSING, None): if default_reaction_emoji is not MISSING:
if isinstance(default_reaction_emoji, _EmojiTag): if isinstance(default_reaction_emoji, _EmojiTag):
options['default_reaction_emoji'] = default_reaction_emoji._to_partial()._to_forum_tag_payload() options['default_reaction_emoji'] = default_reaction_emoji._to_partial()._to_forum_tag_payload()
elif isinstance(default_reaction_emoji, str): elif isinstance(default_reaction_emoji, str):
@ -1723,7 +1723,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 not in (MISSING, None): if 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__}'

Loading…
Cancel
Save