mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-25 02:23:04 +00:00 
			
		
		
		
	Expose Embed.from_data as Embed.from_dict
This is a breaking change.
This commit is contained in:
		| @@ -112,7 +112,21 @@ class Embed: | |||||||
|             self.timestamp = timestamp |             self.timestamp = timestamp | ||||||
|  |  | ||||||
|     @classmethod |     @classmethod | ||||||
|     def from_data(cls, data): |     def from_dict(cls, data): | ||||||
|  |         """Converts a :class:`dict` to a :class:`Embed` provided it is in the | ||||||
|  |         format that Discord expects it to be in. | ||||||
|  |  | ||||||
|  |         You can find out about this format in the `official Discord documentation`__. | ||||||
|  |  | ||||||
|  |         .. _DiscordDocs: https://discordapp.com/developers/docs/resources/channel#embed-object | ||||||
|  |  | ||||||
|  |         __ DiscordDocs_ | ||||||
|  |  | ||||||
|  |         Parameters | ||||||
|  |         ----------- | ||||||
|  |         data: :class:`dict` | ||||||
|  |             The dictionary to convert into an embed. | ||||||
|  |         """ | ||||||
|         # we are bypassing __init__ here since it doesn't apply here |         # we are bypassing __init__ here since it doesn't apply here | ||||||
|         self = cls.__new__(cls) |         self = cls.__new__(cls) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -281,7 +281,7 @@ class Message: | |||||||
|         self._try_patch(data, 'type', lambda x: try_enum(MessageType, x)) |         self._try_patch(data, 'type', lambda x: try_enum(MessageType, x)) | ||||||
|         self._try_patch(data, 'content') |         self._try_patch(data, 'content') | ||||||
|         self._try_patch(data, 'attachments', lambda x: [Attachment(data=a, state=self._state) for a in x]) |         self._try_patch(data, 'attachments', lambda x: [Attachment(data=a, state=self._state) for a in x]) | ||||||
|         self._try_patch(data, 'embeds', lambda x: list(map(Embed.from_data, x))) |         self._try_patch(data, 'embeds', lambda x: list(map(Embed.from_dict, x))) | ||||||
|         self._try_patch(data, 'nonce') |         self._try_patch(data, 'nonce') | ||||||
|  |  | ||||||
|         for handler in ('author', 'member', 'mentions', 'mention_roles', 'call'): |         for handler in ('author', 'member', 'mentions', 'mention_roles', 'call'): | ||||||
|   | |||||||
| @@ -391,7 +391,7 @@ class ConnectionState: | |||||||
|                 message._handle_call(data['call']) |                 message._handle_call(data['call']) | ||||||
|             elif 'content' not in data: |             elif 'content' not in data: | ||||||
|                 # embed only edit |                 # embed only edit | ||||||
|                 message.embeds = [Embed.from_data(d) for d in data['embeds']] |                 message.embeds = [Embed.from_dict(d) for d in data['embeds']] | ||||||
|             else: |             else: | ||||||
|                 message._update(channel=message.channel, data=data) |                 message._update(channel=message.channel, data=data) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user