mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 00:13:01 +00:00
Allow creating a news channel in create_text_channel
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user