Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(channel): add GroupChannel.get_partial_message #1256

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading