Allow more methods to set an audit log reason

This commit is contained in:
Nadir Chowdhury
2020-07-01 04:35:42 +01:00
committed by GitHub
parent de556b01d1
commit e971e2f16c
4 changed files with 59 additions and 23 deletions

View File

@@ -856,7 +856,7 @@ class Message:
await self._state.http.publish_message(self.channel.id, self.id)
async def pin(self):
async def pin(self, *, reason=None):
"""|coro|
Pins the message.
@@ -864,6 +864,13 @@ class Message:
You must have the :attr:`~Permissions.manage_messages` permission to do
this in a non-private channel context.
Parameters
-----------
reason: Optional[:class:`str`]
The reason for pinning the message. Shows up on the audit log.
.. versionadded:: 1.4
Raises
-------
Forbidden
@@ -875,10 +882,10 @@ class Message:
having more than 50 pinned messages.
"""
await self._state.http.pin_message(self.channel.id, self.id)
await self._state.http.pin_message(self.channel.id, self.id, reason=reason)
self.pinned = True
async def unpin(self):
async def unpin(self, *, reason=None):
"""|coro|
Unpins the message.
@@ -886,6 +893,13 @@ class Message:
You must have the :attr:`~Permissions.manage_messages` permission to do
this in a non-private channel context.
Parameters
-----------
reason: Optional[:class:`str`]
The reason for pinning the message. Shows up on the audit log.
.. versionadded:: 1.4
Raises
-------
Forbidden
@@ -896,7 +910,7 @@ class Message:
Unpinning the message failed.
"""
await self._state.http.unpin_message(self.channel.id, self.id)
await self._state.http.unpin_message(self.channel.id, self.id, reason=reason)
self.pinned = False
async def add_reaction(self, emoji):