test for silent message deleting
This commit is contained in:
parent
89d2f00911
commit
316e74a9ec
@ -910,7 +910,7 @@ class Message(Hashable):
|
||||
if self.type is MessageType.channel_follow_add:
|
||||
return '{0.author.name} has added {0.content} to this channel'.format(self)
|
||||
|
||||
async def delete(self, *, delay=None):
|
||||
async def delete(self, *, delay=None, silent=False):
|
||||
"""|coro|
|
||||
|
||||
Deletes the message.
|
||||
@ -922,12 +922,17 @@ class Message(Hashable):
|
||||
.. versionchanged:: 1.1
|
||||
Added the new ``delay`` keyword-only parameter.
|
||||
|
||||
.. versionchanged:: 1.6.0.7
|
||||
ADded the new ``silent`` keyword-only parameter.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
delay: Optional[:class:`float`]
|
||||
If provided, the number of seconds to wait in the background
|
||||
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
|
||||
------
|
||||
Forbidden
|
||||
@ -947,7 +952,13 @@ class Message(Hashable):
|
||||
|
||||
asyncio.ensure_future(delete(), loop=self._state.loop)
|
||||
else:
|
||||
await self._state.http.delete_message(self.channel.id, self.id)
|
||||
try:
|
||||
await self._state.http.delete_message(self.channel.id, self.id)
|
||||
except Exception as e:
|
||||
if silent:
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
async def edit(self, **fields):
|
||||
"""|coro|
|
||||
|
Loading…
x
Reference in New Issue
Block a user