aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-14 09:42:38 -0400
committerRapptz <[email protected]>2021-06-08 07:25:30 -0400
commitc1ce3b949fe2dbc3d34a86d3a7973a7ed60566df (patch)
tree81d26aa3a3f2e4ccb3b60cf2c84893c317250f24 /discord/message.py
parentFirst pass at preliminary thread support (diff)
downloaddiscord.py-c1ce3b949fe2dbc3d34a86d3a7973a7ed60566df.tar.xz
discord.py-c1ce3b949fe2dbc3d34a86d3a7973a7ed60566df.zip
Implement remaining HTTP endpoints on threads
I'm not sure if I missed any -- but this is the entire documented set so far.
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/discord/message.py b/discord/message.py
index 42ef6bf7..dc240d29 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -46,6 +46,7 @@ from .utils import escape_mentions
from .guild import Guild
from .mixins import Hashable
from .sticker import Sticker
+from .threads import Thread
if TYPE_CHECKING:
from .types.message import (
@@ -58,7 +59,7 @@ if TYPE_CHECKING:
)
from .types.components import Component as ComponentPayload
-
+ from .types.threads import ThreadArchiveDuration
from .types.member import Member as MemberPayload
from .types.user import User as UserPayload
from .types.embed import Embed as EmbedPayload
@@ -79,7 +80,6 @@ __all__ = (
'DeletedReferencedMessage',
)
-
def convert_emoji_reaction(emoji):
if isinstance(emoji, Reaction):
emoji = emoji.emoji
@@ -1429,6 +1429,45 @@ 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:
+ """|coro|
+
+ Starts a public thread from this message.
+
+ You must have :attr:`~discord.Permissions.send_messages` and
+ :attr:`~discord.Permissions.use_threads` in order to start a thread.
+
+ The channel this message belongs in must be a :class:`TextChannel`.
+
+ Parameters
+ -----------
+ name: :class:`str`
+ The name of the thread.
+ auto_archive_duration: :class:`int`
+ The duration in minutes before a thread is automatically archived for inactivity.
+ Defaults to ``1440`` or 24 hours.
+
+ Raises
+ -------
+ Forbidden
+ You do not have permissions to start a thread.
+ HTTPException
+ Starting the thread failed.
+ InvalidArgument
+ This message does not have guild info attached.
+ """
+ if self.guild is None:
+ raise InvalidArgument('This message does not have guild info attached.')
+
+ data = await self._state.http.start_public_thread(
+ self.channel.id,
+ self.id,
+ name=name,
+ auto_archive_duration=auto_archive_duration,
+ type=ChannelType.public_thread.value,
+ )
+ return Thread(guild=self.guild, data=data) # type: ignore
+
async def reply(self, content: Optional[str] = None, **kwargs) -> Message:
"""|coro|