Skip to content
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
13 changes: 13 additions & 0 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from .enums import ChannelType
from .errors import ClientException, InvalidArgument
from .file import File
from .flags import MessageFlags
from .invite import Invite
from .iterators import HistoryIterator
from .mentions import AllowedMentions
Expand Down Expand Up @@ -1256,6 +1257,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
suppress: bool = ...,
) -> Message:
...

Expand All @@ -1274,6 +1276,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
suppress: bool = ...,
) -> Message:
...

Expand All @@ -1292,6 +1295,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
suppress: bool = ...,
) -> Message:
...

Expand All @@ -1310,6 +1314,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
suppress: bool = ...,
) -> Message:
...

Expand All @@ -1329,6 +1334,7 @@ async def send(
reference=None,
mention_author=None,
view=None,
suppress=None
):
"""|coro|

Expand Down Expand Up @@ -1401,6 +1407,8 @@ async def send(
A list of stickers to upload. Must be a maximum of 3.

.. versionadded:: 2.0
suppress: :class:`bool`
Whether to suppress embeds for the message.

Raises
--------
Expand Down Expand Up @@ -1435,6 +1443,8 @@ async def send(
if len(embeds) > 10:
raise InvalidArgument("embeds parameter must be a list of up to 10 elements")
embeds = [embed.to_dict() for embed in embeds]

flags = MessageFlags.suppress_embeds if suppress else MessageFlags.DEFAULT_VALUE

if stickers is not None:
stickers = [sticker.id for sticker in stickers]
Expand Down Expand Up @@ -1486,6 +1496,7 @@ async def send(
message_reference=reference,
stickers=stickers,
components=components,
flags=flags,
)
finally:
file.close()
Expand All @@ -1509,6 +1520,7 @@ async def send(
message_reference=reference,
stickers=stickers,
components=components,
flags=flags,
)
finally:
for f in files:
Expand All @@ -1525,6 +1537,7 @@ async def send(
message_reference=reference,
stickers=stickers,
components=components,
flags=flags,
)

ret = state.create_message(channel=channel, data=data)
Expand Down
9 changes: 9 additions & 0 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def send_message(
message_reference: Optional[message.MessageReference] = None,
stickers: Optional[List[sticker.StickerItem]] = None,
components: Optional[List[components.Component]] = None,
flags: Optional[int] = None,
) -> Response[message.Message]:
r = Route("POST", "/channels/{channel_id}/messages", channel_id=channel_id)
payload = {}
Expand Down Expand Up @@ -479,6 +480,9 @@ def send_message(

if stickers:
payload["sticker_ids"] = stickers

if flags:
payload["flags"] = flags

return self.request(r, json=payload)

Expand All @@ -499,6 +503,7 @@ def send_multipart_helper(
message_reference: Optional[message.MessageReference] = None,
stickers: Optional[List[sticker.StickerItem]] = None,
components: Optional[List[components.Component]] = None,
flags: Optional[int] = None,
) -> Response[message.Message]:
form = []

Expand All @@ -519,6 +524,8 @@ def send_multipart_helper(
payload["components"] = components
if stickers:
payload["sticker_ids"] = stickers
if flags:
payload["flags"] = flags

attachments = []
form.append({"name": "payload_json"})
Expand Down Expand Up @@ -556,6 +563,7 @@ def send_files(
message_reference: Optional[message.MessageReference] = None,
stickers: Optional[List[sticker.StickerItem]] = None,
components: Optional[List[components.Component]] = None,
flags: Optional[int] = None,
) -> Response[message.Message]:
r = Route("POST", "/channels/{channel_id}/messages", channel_id=channel_id)
return self.send_multipart_helper(
Expand All @@ -570,6 +578,7 @@ def send_files(
message_reference=message_reference,
stickers=stickers,
components=components,
flags=flags,
)

def edit_multipart_helper(
Expand Down