@@ -1814,8 +1814,6 @@ async def edit(self, **fields: Any) -> Optional[Message]:
18141814
18151815 Edits the message.
18161816
1817- The content must be able to be transformed into a string via ``str(content)``.
1818-
18191817 .. versionchanged:: 1.7
18201818 :class:`discord.Message` is returned instead of ``None`` if an edit took place.
18211819
@@ -1824,9 +1822,13 @@ async def edit(self, **fields: Any) -> Optional[Message]:
18241822 content: Optional[:class:`str`]
18251823 The new content to replace the message with.
18261824 Could be ``None`` to remove the content.
1827- embed: Optional[:class:`Embed`]
1825+ embed: Optional[:class:`~discord. Embed`]
18281826 The new embed to replace the original with.
18291827 Could be ``None`` to remove the embed.
1828+ embeds: Optional[List[:class:`~discord.Embed`]]
1829+ A list of embeds to upload. Must be a maximum of 10.
1830+
1831+ .. versionadded:: 2.0
18301832 suppress: :class:`bool`
18311833 Whether to suppress embeds for the message. This removes
18321834 all the embeds if set to ``True``. If set to ``False``
@@ -1865,53 +1867,43 @@ async def edit(self, **fields: Any) -> Optional[Message]:
18651867 The message that was edited.
18661868 """
18671869
1868- try :
1869- content = fields ["content" ]
1870- except KeyError :
1871- pass
1872- else :
1873- if content is not None :
1874- fields ["content" ] = str (content )
1870+ content = fields .pop ("content" , MISSING )
1871+ if content is not MISSING :
1872+ fields ["content" ] = str (content )
18751873
1876- try :
1877- embed = fields ["embed" ]
1878- except KeyError :
1879- pass
1880- else :
1881- if embed is not None :
1882- fields ["embed" ] = embed .to_dict ()
1874+ embed = fields .pop ("embed" , MISSING )
1875+ embeds = fields .pop ("embeds" , MISSING )
18831876
1884- try :
1885- suppress : bool = fields .pop ("suppress" )
1886- except KeyError :
1887- pass
1888- else :
1889- flags = MessageFlags ._from_value (0 )
1890- flags .suppress_embeds = suppress
1891- fields ["flags" ] = flags .value
1877+ if embed is not MISSING and embeds is not MISSING :
1878+ raise InvalidArgument ("Cannot pass both embed and embeds parameters." )
1879+
1880+ if embed is not MISSING :
1881+ fields ["embeds" ] = [embed .to_dict ()]
1882+
1883+ if embeds is not MISSING :
1884+ fields ["embeds" ] = [embed .to_dict () for embed in embeds ]
1885+
1886+ suppress = fields .pop ("suppress" , False )
1887+ flags = MessageFlags ._from_value (0 )
1888+ flags .suppress_embeds = suppress
1889+ fields ["flags" ] = flags .value
18921890
18931891 delete_after = fields .pop ("delete_after" , None )
18941892
1895- try :
1896- allowed_mentions = fields .pop ("allowed_mentions" )
1897- except KeyError :
1898- pass
1893+ allowed_mentions = fields .get ("allowed_mentions" , MISSING )
1894+ if allowed_mentions is not MISSING :
1895+ if self ._state .allowed_mentions is not None :
1896+ allowed_mentions = self ._state .allowed_mentions .merge (allowed_mentions ).to_dict ()
1897+ else :
1898+ allowed_mentions = allowed_mentions .to_dict ()
1899+ fields ["allowed_mentions" ] = allowed_mentions
18991900 else :
1900- if allowed_mentions is not None :
1901- if self ._state .allowed_mentions is not None :
1902- allowed_mentions = self ._state .allowed_mentions .merge (allowed_mentions ).to_dict ()
1903- else :
1904- allowed_mentions = allowed_mentions .to_dict ()
1905- fields ["allowed_mentions" ] = allowed_mentions
1901+ fields ["allowed_mentions" ] = self ._state .allowed_mentions .to_dict () if self ._state .allowed_mentions else None
1902+
1903+ view = fields .pop ("view" , None )
1904+ self ._state .prevent_view_updates_for (self .id )
1905+ fields ["components" ] = view .to_components () if view else []
19061906
1907- try :
1908- view = fields .pop ("view" )
1909- except KeyError :
1910- # To check for the view afterwards
1911- view = None
1912- else :
1913- self ._state .prevent_view_updates_for (self .id )
1914- fields ["components" ] = view .to_components () if view else []
19151907 if fields :
19161908 data = await self ._state .http .edit_message (self .channel .id , self .id , ** fields )
19171909
0 commit comments