add back the silent kwarg to message.delete (#9)

* add back the silent kwarg to message.delete

* forgot about versionadded

* shorten the if statement

* simplify raising a bit ig?

* should be versionchanged instead

Co-authored-by: Arthur <site-github@api-d.com>

* remove `Optional` from parameter and doc string

Co-authored-by: Arthur <site-github@api-d.com>
This commit is contained in:
Moksej 2021-08-29 19:57:07 +02:00 committed by GitHub
parent de0e8ef108
commit 773ad6f5bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1106,7 +1106,7 @@ class Message(Hashable):
if self.type is MessageType.guild_invite_reminder: if self.type is MessageType.guild_invite_reminder:
return 'Wondering who to invite?\nStart by inviting anyone who can help you build the server!' return 'Wondering who to invite?\nStart by inviting anyone who can help you build the server!'
async def delete(self, *, delay: Optional[float] = None) -> None: async def delete(self, *, delay: Optional[float] = None, silent: bool = False) -> None:
"""|coro| """|coro|
Deletes the message. Deletes the message.
@ -1117,12 +1117,17 @@ class Message(Hashable):
.. versionchanged:: 1.1 .. versionchanged:: 1.1
Added the new ``delay`` keyword-only parameter. Added the new ``delay`` keyword-only parameter.
.. versionchanged:: 2.0
Added the new ``silent`` keyword-only parameter.
Parameters Parameters
----------- -----------
delay: Optional[:class:`float`] delay: Optional[:class:`float`]
If provided, the number of seconds to wait in the background If provided, the number of seconds to wait in the background
before deleting the message. If the deletion fails then it is silently ignored. before deleting the message. If the deletion fails then it is silently ignored.
silent: :class:`bool`
If silent is set to ``True``, the error will not be raised, it will be ignored.
This defaults to ``False``
Raises Raises
------ ------
@ -1144,7 +1149,11 @@ class Message(Hashable):
asyncio.create_task(delete(delay)) asyncio.create_task(delete(delay))
else: else:
try:
await self._state.http.delete_message(self.channel.id, self.id) await self._state.http.delete_message(self.channel.id, self.id)
except Exception:
if not silent:
raise
@overload @overload
async def edit( async def edit(