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(message): implement message forwarding #1188

Merged
merged 38 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e232ef2
implement message forwarding
Snipy7374 Apr 25, 2024
2291ba7
finalize feature
Snipy7374 Apr 27, 2024
c219eb0
add documentation for message forward method
Snipy7374 Apr 27, 2024
f01eba6
update changelog
Snipy7374 Apr 27, 2024
4b20515
add MessageReferenceType to the docs
Snipy7374 Apr 27, 2024
ba2dd4e
fix docs
Snipy7374 Apr 27, 2024
c1a6551
fix: make users be able to choose where to send forwards
Snipy7374 Apr 30, 2024
35acee8
Update disnake/abc.py
Snipy7374 Nov 14, 2024
f5da391
Update disnake/message.py
Snipy7374 Nov 14, 2024
c572922
feat: implement new attributes for ForwardedMessage class and fix doc…
Snipy7374 Nov 14, 2024
0d32187
Merge branch 'master' into feat/forward
Snipy7374 Nov 14, 2024
ed8bd63
fix: docstrings and run pre-commit
Snipy7374 Nov 14, 2024
b45c2cc
fix: remove old interaction attr - wrong conflicts resolution :'(
Snipy7374 Nov 14, 2024
8db23bf
Update disnake/abc.py
Snipy7374 Nov 16, 2024
c9181d0
Update disnake/message.py
Snipy7374 Nov 16, 2024
fb8a4b7
Update disnake/message.py
Snipy7374 Nov 16, 2024
32f682b
Update docs/api/messages.rst
Snipy7374 Nov 16, 2024
f93efc8
Update disnake/message.py
Snipy7374 Nov 16, 2024
bbbc5c7
Update disnake/message.py
Snipy7374 Nov 16, 2024
9e54d14
feat: apply suggested changes
Snipy7374 Nov 16, 2024
d4fe03f
Merge branch 'feat/forward' of github.com:Snipy7374/disnake into feat…
Snipy7374 Nov 16, 2024
dfb26ff
feat: implement forward on PartialMessage
Snipy7374 Nov 16, 2024
3a03f69
fix: remove useless variable
Snipy7374 Nov 16, 2024
cfeffe1
fix: make type required to forward in TypedDict, remove TODO comment …
Snipy7374 Nov 16, 2024
e7d9a60
feat: implement logic for mentions and role_mentions (mention_roles) …
Snipy7374 Nov 16, 2024
ef05e6c
feat: refeactor mention and role_mentions attrs build for ForwardedMe…
Snipy7374 Nov 16, 2024
ffe679f
fix: make annotations for _handle_mentions and Member._try_upgrade co…
Snipy7374 Nov 18, 2024
774be89
Merge branch 'master' into feat/forward
Snipy7374 Nov 18, 2024
0473453
Update disnake/message.py
Snipy7374 Nov 21, 2024
f1a28d0
Merge branch 'master' into feat/forward
Snipy7374 Nov 22, 2024
f7ed3fa
implement properties on ForwardedMessage
Snipy7374 Nov 22, 2024
a16b05d
update docstrings and slots
Snipy7374 Nov 22, 2024
1eff409
feat: add new message flag for forwarded messages
Snipy7374 Nov 22, 2024
ac8acb1
reformat docstrings
Snipy7374 Nov 22, 2024
b4918b5
run codemod scripts
Snipy7374 Nov 22, 2024
05930d2
Update docs/api/messages.rst
Snipy7374 Dec 11, 2024
d771282
Update docs/api/messages.rst
Snipy7374 Dec 11, 2024
7b416e5
Merge branch 'master' into feat/forward
Snipy7374 Dec 11, 2024
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/1187.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for message forwarding. New :class:`ForwardedMessage`, new enum :class:`MessageReferenceType`, new method :func:`Message.forward`, edited :class:`MessageReference` to support message forwarding.
6 changes: 6 additions & 0 deletions disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,12 @@ async def send(

.. versionadded:: 1.6

.. note::

Passing a :class:`.Message` or :class:`.PartialMessage` will only allow replies. To forward a message
you must explicitly transform the message to a :class:`.MessageReference` using :meth:`.Message.to_reference` and specify the :class:`.MessageReferenceType`,
or use :meth:`.Message.forward`.

mention_author: Optional[:class:`bool`]
If set, overrides the :attr:`.AllowedMentions.replied_user` attribute of ``allowed_mentions``.

Expand Down
8 changes: 8 additions & 0 deletions disnake/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"EntitlementType",
"PollLayoutType",
"VoiceChannelEffectAnimationType",
"MessageReferenceType",
)


Expand Down Expand Up @@ -1415,6 +1416,13 @@ class VoiceChannelEffectAnimationType(Enum):
basic = 1


class MessageReferenceType(Enum):
default = 0
"""A standard message reference used in message replies."""
forward = 1
"""Reference used to point to a message at a point in time (forward)."""


T = TypeVar("T")


Expand Down
11 changes: 11 additions & 0 deletions disnake/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def __init__(
crossposted: bool = ...,
ephemeral: bool = ...,
failed_to_mention_roles_in_thread: bool = ...,
has_snapshot: bool = ...,
has_thread: bool = ...,
is_crossposted: bool = ...,
is_voice_message: bool = ...,
Expand Down Expand Up @@ -678,6 +679,16 @@ def is_voice_message(self):
"""
return 1 << 13

@flag_value
def has_snapshot(self):
""":class:`bool`: Returns ``True`` if the message is a forward message.

Messages with this flag will have only the forward data, and no other content.

.. versionadded:: 2.10
"""
return 1 << 14


class PublicUserFlags(BaseFlags):
"""Wraps up the Discord User Public flags.
Expand Down
8 changes: 6 additions & 2 deletions disnake/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,15 @@ def _update_from_message(self, data: MemberPayload) -> None:

@classmethod
def _try_upgrade(
cls, *, data: UserWithMemberPayload, guild: Guild, state: ConnectionState
cls,
*,
data: Union[UserPayload, UserWithMemberPayload],
guild: Guild,
state: ConnectionState,
) -> Union[User, Self]:
# A User object with a 'member' key
try:
member_data = data.pop("member")
member_data = data.pop("member") # type: ignore
except KeyError:
return state.create_user(data)
else:
Expand Down
Loading
Loading