Allow creating a news channel in create_text_channel

This commit is contained in:
Rapptz
2022-04-30 07:12:16 -04:00
parent 20a7961e19
commit 0851e03f00
2 changed files with 16 additions and 5 deletions

View File

@@ -1127,11 +1127,11 @@ class Guild(Hashable):
def _create_channel(
self,
name: str,
channel_type: Literal[ChannelType.text],
channel_type: Literal[ChannelType.news, ChannelType.text],
overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = ...,
category: Optional[Snowflake] = ...,
**options: Any,
) -> Coroutine[Any, Any, GuildChannelPayload]:
) -> Coroutine[Any, Any, Union[TextChannelPayload, NewsChannelPayload]]:
...
@overload
@@ -1184,6 +1184,7 @@ class Guild(Hashable):
*,
reason: Optional[str] = None,
category: Optional[CategoryChannel] = None,
news: bool = False,
position: int = MISSING,
topic: str = MISSING,
slowmode_delay: int = MISSING,
@@ -1255,6 +1256,10 @@ class Guild(Hashable):
The maximum value possible is `21600`.
nsfw: :class:`bool`
To mark the channel as NSFW or not.
news: :class:`bool`
Whether to create the text channel as a news channel.
.. versionadded:: 2.0
default_auto_archive_duration: :class:`int`
The default auto archive duration for threads created in the text channel (in minutes).
@@ -1294,7 +1299,12 @@ class Guild(Hashable):
options["default_auto_archive_duration"] = default_auto_archive_duration
data = await self._create_channel(
name, overwrites=overwrites, channel_type=ChannelType.text, category=category, reason=reason, **options
name,
overwrites=overwrites,
channel_type=ChannelType.news if news else ChannelType.text,
category=category,
reason=reason,
**options,
)
channel = TextChannel(state=self._state, guild=self, data=data)