aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-29 20:31:54 -0500
committerRapptz <[email protected]>2017-01-29 20:32:24 -0500
commitb27fab09eb411dfdb51c3c43a81d51a4f5710adf (patch)
treea7e6962f9f8740c57c61b7e58e0cbd5ee54ac54c /discord/message.py
parentAdd missing int casts in many different events in the state. (diff)
downloaddiscord.py-b27fab09eb411dfdb51c3c43a81d51a4f5710adf.tar.xz
discord.py-b27fab09eb411dfdb51c3c43a81d51a4f5710adf.zip
Allow removing an embed in Message.edit
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/discord/message.py b/discord/message.py
index acf4da2c..d4367f23 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -416,7 +416,7 @@ class Message:
yield from self._state.http.delete_message(self.channel.id, self.id)
@asyncio.coroutine
- def edit(self, *, content: str = None, embed: Embed = None):
+ def edit(self, **fields):
"""|coro|
Edits the message.
@@ -427,8 +427,9 @@ class Message:
-----------
content: str
The new content to replace the message with.
- embed: :class:`Embed`
+ embed: Optional[:class:`Embed`]
The new embed to replace the original with.
+ Could be ``None`` to remove the embed.
Raises
-------
@@ -436,9 +437,23 @@ class Message:
Editing the message failed.
"""
- content = str(content) if content else None
- embed = embed.to_dict() if embed else None
- data = yield from self._state.http.edit_message(self.id, self.channel.id, content, embed=embed)
+ try:
+ content = fields['content']
+ 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)
@asyncio.coroutine