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 forwarding #2598

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
22 changes: 16 additions & 6 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,8 @@ async def send(
.. versionadded:: 1.4

reference: Union[:class:`~discord.Message`, :class:`~discord.MessageReference`, :class:`~discord.PartialMessage`]
A reference to the :class:`~discord.Message` to which you are replying, this can be created using
:meth:`~discord.Message.to_reference` or passed directly as a :class:`~discord.Message`. You can control
A reference to the :class:`~discord.Message` you are replying to or forwarding, this can be created using
:meth:`~discord.Message.to_reference` or passed directly as a :class:`~discord.Message`. When replying, you can control
whether this mentions the author of the referenced message using the
:attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions`` or by
setting ``mention_author``.
Expand Down Expand Up @@ -1587,9 +1587,19 @@ async def send(
allowed_mentions = allowed_mentions or AllowedMentions().to_dict()
allowed_mentions["replied_user"] = bool(mention_author)

_reference = None
if reference is not None:
try:
reference = reference.to_message_reference_dict()
_reference = reference.to_message_reference_dict()
from .message import MessageReference

if not isinstance(reference, MessageReference):
utils.warn_deprecated(
f"Passing {type(reference).__name__} to reference",
"MessageReference",
"2.7",
"3.0",
)
except AttributeError:
raise InvalidArgument(
"reference parameter must be Message, MessageReference, or"
Expand Down Expand Up @@ -1627,7 +1637,7 @@ async def send(
embeds=embeds,
nonce=nonce,
enforce_nonce=enforce_nonce,
message_reference=reference,
message_reference=_reference,
stickers=stickers,
components=components,
flags=flags,
Expand Down Expand Up @@ -1655,7 +1665,7 @@ async def send(
nonce=nonce,
enforce_nonce=enforce_nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
message_reference=_reference,
stickers=stickers,
components=components,
flags=flags,
Expand All @@ -1674,7 +1684,7 @@ async def send(
nonce=nonce,
enforce_nonce=enforce_nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
message_reference=_reference,
stickers=stickers,
components=components,
flags=flags,
Expand Down
15 changes: 15 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"EntitlementOwnerType",
"IntegrationType",
"InteractionContextType",
"PollLayoutType",
"MessageReferenceType",
)


Expand Down Expand Up @@ -266,6 +268,12 @@ class MessageType(Enum):
stage_raise_hand = 30
stage_topic = 31
guild_application_premium_subscription = 32
guild_incident_alert_mode_enabled = 36
guild_incident_alert_mode_disabled = 37
guild_incident_report_raid = 38
guild_incident_report_false_alarm = 39
purchase_notification = 44
poll_result = 46


class VoiceRegion(Enum):
Expand Down Expand Up @@ -1054,6 +1062,13 @@ class PollLayoutType(Enum):
default = 1


class MessageReferenceType(Enum):
"""The message reference's type"""

default = 0
forward = 1


T = TypeVar("T")


Expand Down
Loading