Allow removing an embed in Message.edit
This commit is contained in:
parent
554ae196d3
commit
b27fab09eb
@ -318,18 +318,10 @@ class HTTPClient:
|
|||||||
|
|
||||||
return self.request(r, json=payload)
|
return self.request(r, json=payload)
|
||||||
|
|
||||||
def edit_message(self, message_id, channel_id, content, *, embed=None):
|
def edit_message(self, message_id, channel_id, **fields):
|
||||||
r = Route('PATCH', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id,
|
r = Route('PATCH', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id,
|
||||||
message_id=message_id)
|
message_id=message_id)
|
||||||
payload = {}
|
return self.request(r, json=fields)
|
||||||
|
|
||||||
if content:
|
|
||||||
payload['content'] = content
|
|
||||||
|
|
||||||
if embed:
|
|
||||||
payload['embed'] = embed
|
|
||||||
|
|
||||||
return self.request(r, json=payload)
|
|
||||||
|
|
||||||
def add_reaction(self, message_id, channel_id, emoji):
|
def add_reaction(self, message_id, channel_id, emoji):
|
||||||
r = Route('PUT', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me',
|
r = Route('PUT', '/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me',
|
||||||
|
@ -416,7 +416,7 @@ class Message:
|
|||||||
yield from self._state.http.delete_message(self.channel.id, self.id)
|
yield from self._state.http.delete_message(self.channel.id, self.id)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def edit(self, *, content: str = None, embed: Embed = None):
|
def edit(self, **fields):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Edits the message.
|
Edits the message.
|
||||||
@ -427,8 +427,9 @@ class Message:
|
|||||||
-----------
|
-----------
|
||||||
content: str
|
content: str
|
||||||
The new content to replace the message with.
|
The new content to replace the message with.
|
||||||
embed: :class:`Embed`
|
embed: Optional[:class:`Embed`]
|
||||||
The new embed to replace the original with.
|
The new embed to replace the original with.
|
||||||
|
Could be ``None`` to remove the embed.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -436,9 +437,23 @@ class Message:
|
|||||||
Editing the message failed.
|
Editing the message failed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
content = str(content) if content else None
|
try:
|
||||||
embed = embed.to_dict() if embed else None
|
content = fields['content']
|
||||||
data = yield from self._state.http.edit_message(self.id, self.channel.id, content, embed=embed)
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if content is not None:
|
||||||
|
fields['content'] = str(content)
|
||||||
|
|
||||||
|
try:
|
||||||
|
embed = fields['embed']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if embed is not None:
|
||||||
|
fields['embed'] = embed.to_dict()
|
||||||
|
|
||||||
|
data = yield from self._state.http.edit_message(self.id, self.channel.id, **fields)
|
||||||
self._update(channel=self.channel, data=data)
|
self._update(channel=self.channel, data=data)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user