Support message editing with rich embeds.
This commit is contained in:
		| @@ -1374,13 +1374,16 @@ class Client: | |||||||
|                     ret.append(msg) |                     ret.append(msg) | ||||||
|  |  | ||||||
|     @asyncio.coroutine |     @asyncio.coroutine | ||||||
|     def edit_message(self, message, new_content): |     def edit_message(self, message, new_content=None, *, embed=None): | ||||||
|         """|coro| |         """|coro| | ||||||
|  |  | ||||||
|         Edits a :class:`Message` with the new message content. |         Edits a :class:`Message` with the new message content. | ||||||
|  |  | ||||||
|         The new_content must be able to be transformed into a string via ``str(new_content)``. |         The new_content must be able to be transformed into a string via ``str(new_content)``. | ||||||
|  |  | ||||||
|  |         If the ``new_content`` is not provided, then ``embed`` must be provided, which must | ||||||
|  |         be of type :class:`Embed`. | ||||||
|  |  | ||||||
|         The :class:`Message` object is not directly modified afterwards until the |         The :class:`Message` object is not directly modified afterwards until the | ||||||
|         corresponding WebSocket event is received. |         corresponding WebSocket event is received. | ||||||
|  |  | ||||||
| @@ -1403,9 +1406,10 @@ class Client: | |||||||
|         """ |         """ | ||||||
|  |  | ||||||
|         channel = message.channel |         channel = message.channel | ||||||
|         content = str(new_content) |         content = str(new_content) if new_content else None | ||||||
|  |         embed = embed.to_dict() if embed else None | ||||||
|         guild_id = channel.server.id if not getattr(channel, 'is_private', True) else None |         guild_id = channel.server.id if not getattr(channel, 'is_private', True) else None | ||||||
|         data = yield from self.http.edit_message(message.id, channel.id, content, guild_id=guild_id) |         data = yield from self.http.edit_message(message.id, channel.id, content, guild_id=guild_id, embed=embed) | ||||||
|         return self.connection._create_message(channel=channel, **data) |         return self.connection._create_message(channel=channel, **data) | ||||||
|  |  | ||||||
|     @asyncio.coroutine |     @asyncio.coroutine | ||||||
|   | |||||||
| @@ -259,11 +259,16 @@ class HTTPClient: | |||||||
|         bucket = '{}:{}'.format(_func_(), guild_id) |         bucket = '{}:{}'.format(_func_(), guild_id) | ||||||
|         return self.post(url, json=payload, bucket=bucket) |         return self.post(url, json=payload, bucket=bucket) | ||||||
|  |  | ||||||
|     def edit_message(self, message_id, channel_id, content, *, guild_id=None): |     def edit_message(self, message_id, channel_id, content, *, guild_id=None, embed=None): | ||||||
|         url = '{0.CHANNELS}/{1}/messages/{2}'.format(self, channel_id, message_id) |         url = '{0.CHANNELS}/{1}/messages/{2}'.format(self, channel_id, message_id) | ||||||
|         payload = { |         payload = {} | ||||||
|             'content': str(content) |  | ||||||
|         } |         if content: | ||||||
|  |             payload['content'] = content | ||||||
|  |  | ||||||
|  |         if embed: | ||||||
|  |             payload['embed'] = embed | ||||||
|  |  | ||||||
|         return self.patch(url, json=payload, bucket='messages:' + str(guild_id)) |         return self.patch(url, json=payload, bucket='messages:' + str(guild_id)) | ||||||
|  |  | ||||||
|     def add_reaction(self, message_id, channel_id, emoji): |     def add_reaction(self, message_id, channel_id, emoji): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user