add back the silent kwarg to message.delete #9

Merged
TheMoksej merged 6 commits from patch-1 into 2.0 2021-08-29 17:57:08 +00:00
Showing only changes of commit 11a9d49fcb - Show all commits

View File

@@ -1106,7 +1106,7 @@ class Message(Hashable):
if self.type is MessageType.guild_invite_reminder:
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: Optional[bool] = False) -> None:
"""|coro|
Deletes the message.
@@ -1123,6 +1123,9 @@ class Message(Hashable):
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: Optional[:class:`bool`]
If silent is set to ``True``, the error will not be raised, it will be ignored.
This defaults to ``False``
Raises
------
@@ -1144,7 +1147,13 @@ class Message(Hashable):
asyncio.create_task(delete(delay))
NiumXp commented 2021-08-28 21:54:14 +00:00 (Migrated from github.com)
Review

You are not using the error, so, you can do

            except Exception:
                if not silent:
                    raise
You are not using the error, so, you can do ```py except Exception: if not silent: raise ```
TheMoksej commented 2021-08-28 22:02:50 +00:00 (Migrated from github.com)
Review

Good point, let me change that

Good point, let me change that
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
@overload
async def edit(