diff options
| author | Rapptz <[email protected]> | 2021-05-04 10:09:05 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-06-08 07:26:22 -0400 |
| commit | b2176dc0efd8b95486d2c1a123404b5a1caf18d2 (patch) | |
| tree | 41cf2ed3f15d4982c5dec44be4ab8cd93ffe976d /discord | |
| parent | Fix import error with threads archived iterator (diff) | |
| download | discord.py-b2176dc0efd8b95486d2c1a123404b5a1caf18d2.tar.xz discord.py-b2176dc0efd8b95486d2c1a123404b5a1caf18d2.zip | |
Change how threads are created
Instead of start_public_thread and start_private_thread they'll now be
one method.
I might revert this if starting a public thread without a message never
ends up happening.
Diffstat (limited to 'discord')
| -rw-r--r-- | discord/channel.py | 47 | ||||
| -rw-r--r-- | discord/message.py | 2 |
2 files changed, 37 insertions, 12 deletions
diff --git a/discord/channel.py b/discord/channel.py index 5e2d16b9..bf145f7a 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -589,18 +589,33 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): from .message import PartialMessage return PartialMessage(channel=self, id=message_id) - async def start_private_thread(self, *, name: str, auto_archive_duration: ThreadArchiveDuration = 1440) -> Thread: + async def start_thread( + self, + *, + name: str, + message: Optional[Snowflake] = None, + auto_archive_duration: ThreadArchiveDuration = 1440, + ) -> Thread: """|coro| - Starts a private thread in this text channel. + Starts a thread in this text channel. + + If no starter message is passed with the ``message`` parameter then + you must have :attr:`~discord.Permissions.send_messages` and + :attr:`~discord.Permissions.use_private_threads` in order to start the thread. - You must have :attr:`~discord.Permissions.send_messages` and - :attr:`~discord.Permissions.use_private_threads` in order to start a thread. + If a starter message is passed with the ``message`` parameter then + you must have :attr:`~discord.Permissions.send_messages` and + :attr:`~discord.Permissions.use_threads` in order to start the thread. Parameters ----------- name: :class:`str` The name of the thread. + message: Optional[:class:`abc.Snowflake`] + A snowflake representing the message to start the thread with. + If ``None`` is passed then a private thread is started. + Defaults to ``None``. auto_archive_duration: :class:`int` The duration in minutes before a thread is automatically archived for inactivity. Defaults to ``1440`` or 24 hours. @@ -613,18 +628,28 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): Starting the thread failed. """ - data = await self._state.http.start_private_thread( - self.id, - name=name, - auto_archive_duration=auto_archive_duration, - type=ChannelType.private_thread.value, - ) + if message is None: + data = await self._state.http.start_private_thread( + self.id, + name=name, + auto_archive_duration=auto_archive_duration, + type=ChannelType.private_thread.value, + ) + else: + data = await self._state.http.start_public_thread( + self.id, + message.id, + name=name, + auto_archive_duration=auto_archive_duration, + type=ChannelType.public_thread.value, + ) + return Thread(guild=self.guild, data=data) def archived_threads( self, *, - private: bool = True, + private: bool = False, joined: bool = False, limit: Optional[int] = 50, before: Optional[Union[Snowflake, datetime.datetime]] = None, diff --git a/discord/message.py b/discord/message.py index 06d7157e..b281707e 100644 --- a/discord/message.py +++ b/discord/message.py @@ -1430,7 +1430,7 @@ class Message(Hashable): """ await self._state.http.clear_reactions(self.channel.id, self.id) - async def start_public_thread(self, *, name: str, auto_archive_duration: ThreadArchiveDuration = 1440) -> Thread: + async def start_thread(self, *, name: str, auto_archive_duration: ThreadArchiveDuration = 1440) -> Thread: """|coro| Starts a public thread from this message. |