Skip to content

Commit

Permalink
feat(channel): add GroupChannel.get_partial_message (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv authored Dec 25, 2024
1 parent a95ddaf commit ad4e85f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/1256.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :meth:`GroupChannel.get_partial_message`.
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 ad4e85f

Please sign in to comment.