Skip to content

Commit

Permalink
Merge pull request #18 from botlabs-gg/discord_forwards_updated
Browse files Browse the repository at this point in the history
Discord forwards updated
  • Loading branch information
amityadav-bst authored Nov 5, 2024
2 parents 602be6f + be423d2 commit 495105e
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 16 deletions.
23 changes: 17 additions & 6 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,8 +1489,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 @@ -1577,9 +1577,20 @@ 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 @@ -1613,7 +1624,7 @@ async def send(
embed=embed,
embeds=embeds,
nonce=nonce,
message_reference=reference,
message_reference=_reference,
stickers=stickers,
components=components,
flags=flags,
Expand All @@ -1639,7 +1650,7 @@ async def send(
embeds=embeds,
nonce=nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
message_reference=_reference,
stickers=stickers,
components=components,
flags=flags,
Expand All @@ -1656,7 +1667,7 @@ async def send(
embeds=embeds,
nonce=nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
message_reference=_reference,
stickers=stickers,
components=components,
flags=flags,
Expand Down
12 changes: 12 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"AutoModKeywordPresetType",
"ApplicationRoleConnectionMetadataType",
"ReactionType",
"MessageReferenceType",
)


Expand Down Expand Up @@ -257,6 +258,7 @@ class MessageType(Enum):
stage_raise_hand = 30
stage_topic = 31
guild_application_premium_subscription = 32
poll_result = 46


class VoiceRegion(Enum):
Expand Down Expand Up @@ -952,6 +954,16 @@ class ReactionType(Enum):
burst = 1



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

default = 0
forward = 1




T = TypeVar("T")


Expand Down
Loading

0 comments on commit 495105e

Please sign in to comment.