[commands] Fix (Partial)MessageConverter to work with thread messages

This commit is contained in:
Nadir Chowdhury authored and GitHub committed 2021-07-10 03:11:34 -04:00
1 parent f153154b7a
commit e2624b9a31
4 files changed
+51 -12

No files matched your search

+26 -1
View File
@@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE.
"""
from __future__ import annotations
from typing import Callable, Dict, Iterable, List, Optional, Union, TYPE_CHECKING
import time
import asyncio
@@ -48,7 +49,7 @@ if TYPE_CHECKING:
from .guild import Guild
from .channel import TextChannel
from .member import Member
from .message import Message
from .message import Message, PartialMessage
from .abc import Snowflake, SnowflakeTime
from .role import Role
from .permissions import Permissions
@@ -191,6 +192,7 @@ class Thread(Messageable, Hashable):
self._unroll_metadata(data['thread_metadata'])
except KeyError:
pass
@property
def type(self) -> ChannelType:
""":class:`ChannelType`: The channel's Discord type."""
@@ -626,6 +628,29 @@ class Thread(Messageable, Hashable):
"""
await self._state.http.delete_channel(self.id)
def get_partial_message(self, message_id: int, /) -> PartialMessage:
"""Creates a :class:`PartialMessage` from the message ID.
This is useful if you want to work with a message and only have its ID without
doing an unnecessary API call.
.. versionadded:: 2.0
Parameters
------------
message_id: :class:`int`
The message ID to create a partial message for.
Returns
---------
:class:`PartialMessage`
The partial message.
"""
from .message import PartialMessage
return PartialMessage(channel=self, id=message_id)
def _add_member(self, member: ThreadMember) -> None:
self._members[member.id] = member