mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-11-04 07:22:50 +00:00 
			
		
		
		
	Re-add support for embeds.
This commit is contained in:
		@@ -140,12 +140,17 @@ class MessageChannel(metaclass=abc.ABCMeta):
 | 
				
			|||||||
        raise NotImplementedError
 | 
					        raise NotImplementedError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @asyncio.coroutine
 | 
					    @asyncio.coroutine
 | 
				
			||||||
    def send_message(self, content, *, tts=False):
 | 
					    def send_message(self, content=None, *, tts=False, embed=None):
 | 
				
			||||||
        """|coro|
 | 
					        """|coro|
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Sends a message to the channel with the content given.
 | 
					        Sends a message to the channel with the content given.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        The content must be a type that can convert to a string through ``str(content)``.
 | 
					        The content must be a type that can convert to a string through ``str(content)``.
 | 
				
			||||||
 | 
					        If the content is set to ``None`` (the default), then the ``embed`` parameter must
 | 
				
			||||||
 | 
					        be provided.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        If the ``embed`` parameter is provided, it must be of type :class:`Embed` and
 | 
				
			||||||
 | 
					        it must be a rich embed type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Parameters
 | 
					        Parameters
 | 
				
			||||||
        ------------
 | 
					        ------------
 | 
				
			||||||
@@ -153,6 +158,8 @@ class MessageChannel(metaclass=abc.ABCMeta):
 | 
				
			|||||||
            The content of the message to send.
 | 
					            The content of the message to send.
 | 
				
			||||||
        tts: bool
 | 
					        tts: bool
 | 
				
			||||||
            Indicates if the message should be sent using text-to-speech.
 | 
					            Indicates if the message should be sent using text-to-speech.
 | 
				
			||||||
 | 
					        embed: :class:`Embed`
 | 
				
			||||||
 | 
					            The rich embed for the content.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Raises
 | 
					        Raises
 | 
				
			||||||
        --------
 | 
					        --------
 | 
				
			||||||
@@ -168,8 +175,11 @@ class MessageChannel(metaclass=abc.ABCMeta):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        channel_id, guild_id = self._get_destination()
 | 
					        channel_id, guild_id = self._get_destination()
 | 
				
			||||||
        content = str(content)
 | 
					        content = str(content) if content else None
 | 
				
			||||||
        data = yield from self._state.http.send_message(channel_id, content, guild_id=guild_id, tts=tts)
 | 
					        if embed is not None:
 | 
				
			||||||
 | 
					            embed = embed.to_dict()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        data = yield from self._state.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
 | 
				
			||||||
        return Message(channel=self, state=self._state, data=data)
 | 
					        return Message(channel=self, state=self._state, data=data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @asyncio.coroutine
 | 
					    @asyncio.coroutine
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -404,7 +404,7 @@ class Message:
 | 
				
			|||||||
        yield from self._state.http.delete_message(self.channel.id, self.id, getattr(self.guild, 'id', None))
 | 
					        yield from self._state.http.delete_message(self.channel.id, self.id, getattr(self.guild, 'id', None))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @asyncio.coroutine
 | 
					    @asyncio.coroutine
 | 
				
			||||||
    def edit(self, *, content: str):
 | 
					    def edit(self, *, content: str = None, embed: Embed = None):
 | 
				
			||||||
        """|coro|
 | 
					        """|coro|
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Edits the message.
 | 
					        Edits the message.
 | 
				
			||||||
@@ -415,6 +415,8 @@ 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`
 | 
				
			||||||
 | 
					            The new embed to replace the original with.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Raises
 | 
					        Raises
 | 
				
			||||||
        -------
 | 
					        -------
 | 
				
			||||||
@@ -423,7 +425,9 @@ class Message:
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        guild_id = getattr(self.guild, 'id', None)
 | 
					        guild_id = getattr(self.guild, 'id', None)
 | 
				
			||||||
        data = yield from self._state.http.edit_message(self.id, self.channel.id, str(content), guild_id=guild_id)
 | 
					        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, guild_id=guild_id, embed=embed)
 | 
				
			||||||
        self._update(channel=self.channel, data=data)
 | 
					        self._update(channel=self.channel, data=data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @asyncio.coroutine
 | 
					    @asyncio.coroutine
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user