Skip to content

Commit

Permalink
feat: add GroupChannel.get_partial_message
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed Dec 14, 2024
1 parent a95ddaf commit 2220825
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions disnake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4968,6 +4968,28 @@ def permissions_for(

return base

def get_partial_message(self, message_id: int, /) -> PartialMessage:
"""Creates a :class:`PartialMessage` from the given 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.10
Parameters
----------
message_id: :class:`int`
The message ID to create a partial message for.
Returns
-------
:class:`PartialMessage`
The partial message object.
"""
from .message import PartialMessage

return PartialMessage(channel=self, id=message_id)

async def leave(self) -> None:
"""|coro|
Expand Down
4 changes: 3 additions & 1 deletion disnake/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,7 @@ class PartialMessage(Hashable):
- :meth:`StageChannel.get_partial_message`
- :meth:`Thread.get_partial_message`
- :meth:`DMChannel.get_partial_message`
- :meth:`GroupChannel.get_partial_message`
- :meth:`PartialMessageable.get_partial_message`
Note that this class is trimmed down and has no rich attributes.
Expand Down Expand Up @@ -2560,14 +2561,15 @@ def __init__(self, *, channel: MessageableChannel, id: int) -> None:
ChannelType.text,
ChannelType.news,
ChannelType.private,
ChannelType.group,
ChannelType.news_thread,
ChannelType.public_thread,
ChannelType.private_thread,
ChannelType.voice,
ChannelType.stage_voice,
):
raise TypeError(
f"Expected TextChannel, VoiceChannel, DMChannel, StageChannel, Thread, or PartialMessageable "
f"Expected TextChannel, VoiceChannel, StageChannel, Thread, DMChannel, GroupChannel, or PartialMessageable "
f"with a valid type, not {type(channel)!r} (type: {channel.type!r})"
)

Expand Down

0 comments on commit 2220825

Please sign in to comment.