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.
This commit is contained in:
parent
40127eb7b5
commit
b2176dc0ef
@ -589,18 +589,33 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
from .message import PartialMessage
|
from .message import PartialMessage
|
||||||
return PartialMessage(channel=self, id=message_id)
|
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|
|
"""|coro|
|
||||||
|
|
||||||
Starts a private thread in this text channel.
|
Starts a thread in this text channel.
|
||||||
|
|
||||||
You must have :attr:`~discord.Permissions.send_messages` and
|
If no starter message is passed with the ``message`` parameter then
|
||||||
:attr:`~discord.Permissions.use_private_threads` in order to start a thread.
|
you must have :attr:`~discord.Permissions.send_messages` and
|
||||||
|
:attr:`~discord.Permissions.use_private_threads` in order to start the 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
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
name: :class:`str`
|
name: :class:`str`
|
||||||
The name of the thread.
|
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`
|
auto_archive_duration: :class:`int`
|
||||||
The duration in minutes before a thread is automatically archived for inactivity.
|
The duration in minutes before a thread is automatically archived for inactivity.
|
||||||
Defaults to ``1440`` or 24 hours.
|
Defaults to ``1440`` or 24 hours.
|
||||||
@ -613,18 +628,28 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
Starting the thread failed.
|
Starting the thread failed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
data = await self._state.http.start_private_thread(
|
if message is None:
|
||||||
self.id,
|
data = await self._state.http.start_private_thread(
|
||||||
name=name,
|
self.id,
|
||||||
auto_archive_duration=auto_archive_duration,
|
name=name,
|
||||||
type=ChannelType.private_thread.value,
|
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)
|
return Thread(guild=self.guild, data=data)
|
||||||
|
|
||||||
def archived_threads(
|
def archived_threads(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
private: bool = True,
|
private: bool = False,
|
||||||
joined: bool = False,
|
joined: bool = False,
|
||||||
limit: Optional[int] = 50,
|
limit: Optional[int] = 50,
|
||||||
before: Optional[Union[Snowflake, datetime.datetime]] = None,
|
before: Optional[Union[Snowflake, datetime.datetime]] = None,
|
||||||
|
@ -1430,7 +1430,7 @@ class Message(Hashable):
|
|||||||
"""
|
"""
|
||||||
await self._state.http.clear_reactions(self.channel.id, self.id)
|
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|
|
"""|coro|
|
||||||
|
|
||||||
Starts a public thread from this message.
|
Starts a public thread from this message.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user