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:
|
if self.type is MessageType.channel_follow_add:
|
||||||
return '{0.author.name} has added {0.content} to this channel'.format(self)
|
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|
|
"""|coro|
|
||||||
|
|
||||||
Deletes the message.
|
Deletes the message.
|
||||||
@ -922,12 +922,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:: 1.6.0.7
|
||||||
|
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
|
||||||
------
|
------
|
||||||
Forbidden
|
Forbidden
|
||||||
@ -947,7 +952,13 @@ class Message(Hashable):
|
|||||||
|
|
||||||
asyncio.ensure_future(delete(), loop=self._state.loop)
|
asyncio.ensure_future(delete(), loop=self._state.loop)
|
||||||
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 as e:
|
||||||
|
if silent:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
async def edit(self, **fields):
|
async def edit(self, **fields):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user