aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-06-21 00:39:52 -0400
committerRapptz <[email protected]>2019-06-29 20:26:47 -0400
commit0cca3ca5c65c8a671cfd23d124ee0b97e61d2272 (patch)
tree5c2f8d3e2319dfce80c3763006fa5e29a2b38316
parentAdd unused Guild.preferred_locale (diff)
downloaddiscord.py-0cca3ca5c65c8a671cfd23d124ee0b97e61d2272.tar.xz
discord.py-0cca3ca5c65c8a671cfd23d124ee0b97e61d2272.zip
Add support for suppressing embeds.
-rw-r--r--discord/http.py6
-rw-r--r--discord/message.py25
2 files changed, 25 insertions, 6 deletions
diff --git a/discord/http.py b/discord/http.py
index 79c03db2..84bd45da 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -374,6 +374,12 @@ class HTTPClient:
r = Route('PATCH', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id, message_id=message_id)
return self.request(r, json=fields)
+ def suppress_message_embeds(self, channel_id, message_id, *, suppress):
+ payload = { 'suppress': suppress }
+ r = Route('POST', '/channels/{channel_id}/messages/{message_id}/suppress-embeds',
+ channel_id=channel_id, message_id=message_id)
+ return self.request(r, json=payload)
+
def add_reaction(self, channel_id, message_id, emoji):
r = Route('PUT', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me',
channel_id=channel_id, message_id=message_id, emoji=emoji)
diff --git a/discord/message.py b/discord/message.py
index 74509bae..e2812c7d 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -711,6 +711,11 @@ class Message:
embed: Optional[:class:`Embed`]
The new embed to replace the original with.
Could be ``None`` to remove the embed.
+ suppress: :class:`bool`
+ Whether to suppress embeds for the message. This removes
+ all the embeds if set to ``True``. If set to ``False``
+ this brings the embeds back if they were suppressed.
+ Using this parameter requires :attr:`~.Permissions.manage_messages`.
delete_after: Optional[:class:`float`]
If provided, the number of seconds to wait in the background
before deleting the message we just edited. If the deletion fails,
@@ -720,6 +725,9 @@ class Message:
-------
HTTPException
Editing the message failed.
+ Forbidden
+ Tried to suppress a message without permissions or
+ edited a message's content or embed that isn't yours.
"""
try:
@@ -738,16 +746,21 @@ class Message:
if embed is not None:
fields['embed'] = embed.to_dict()
- data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
- self._update(data)
-
try:
- delete_after = fields['delete_after']
+ suppress = fields.pop('suppress')
except KeyError:
pass
else:
- if delete_after is not None:
- await self.delete(delay=delete_after)
+ await self._state.http.suppress_message_embeds(self.channel.id, self.id, suppress=suppress)
+
+ delete_after = fields.pop('delete_after', None)
+
+ if fields:
+ data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
+ self._update(data)
+
+ if delete_after is not None:
+ await self.delete(delay=delete_after)
async def pin(self):
"""|coro|