aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-05-01 09:48:37 -0400
committerRapptz <[email protected]>2021-05-01 09:48:37 -0400
commitd9404865522224320e99420239502a654f238e82 (patch)
treebf835aae1bc0977f4dce2a60374a8920d5cd21ed /discord/message.py
parentFix typings for utils._parse_ratelimit_header (diff)
downloaddiscord.py-d9404865522224320e99420239502a654f238e82.tar.xz
discord.py-d9404865522224320e99420239502a654f238e82.zip
Add types to PartialMessage
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py38
1 files changed, 15 insertions, 23 deletions
diff --git a/discord/message.py b/discord/message.py
index 345dc5dc..fd839be4 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -576,8 +576,9 @@ class Message(Hashable):
'_cs_system_content', '_cs_guild', '_state', 'reactions', 'reference',
'application', 'activity', 'stickers')
- _HANDLERS: ClassVar[List[Tuple[str, Callable[..., None]]]]
- _CACHED_SLOTS: ClassVar[List[str]]
+ if TYPE_CHECKING:
+ _HANDLERS: ClassVar[List[Tuple[str, Callable[..., None]]]]
+ _CACHED_SLOTS: ClassVar[List[str]]
def __init__(self, *, state: ConnectionState, channel: Union[TextChannel, DMChannel, GroupChannel], data: MessagePayload):
self._state = state
@@ -1379,14 +1380,7 @@ class Message(Hashable):
return data
-def implement_partial_methods(cls):
- msg = Message
- for name in cls._exported_names:
- func = getattr(msg, name)
- setattr(cls, name, func)
- return cls
-@implement_partial_methods
class PartialMessage(Hashable):
"""Represents a partial message to aid with working messages when only
a message and channel ID are present.
@@ -1423,20 +1417,18 @@ class PartialMessage(Hashable):
__slots__ = ('channel', 'id', '_cs_guild', '_state')
- _exported_names = (
- 'jump_url',
- 'delete',
- 'publish',
- 'pin',
- 'unpin',
- 'add_reaction',
- 'remove_reaction',
- 'clear_reaction',
- 'clear_reactions',
- 'reply',
- 'to_reference',
- 'to_message_reference_dict',
- )
+ jump_url: str = Message.jump_url # type: ignore
+ delete = Message.delete
+ publish = Message.publish
+ pin = Message.pin
+ unpin = Message.unpin
+ add_reaction = Message.add_reaction
+ remove_reaction = Message.remove_reaction
+ clear_reaction = Message.clear_reaction
+ clear_reactions = Message.clear_reactions
+ reply = Message.reply
+ to_reference = Message.to_reference
+ to_message_reference_dict = Message.to_message_reference_dict
def __init__(self, *, channel: Union[GuildChannel, PrivateChannel], id: int):
if channel.type not in (ChannelType.text, ChannelType.news, ChannelType.private):