From e971e2f16cba22decd25db6b44e9cc84adf08555 Mon Sep 17 00:00:00 2001 From: Nadir Chowdhury Date: Wed, 1 Jul 2020 04:35:42 +0100 Subject: Allow more methods to set an audit log reason --- discord/message.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'discord/message.py') diff --git a/discord/message.py b/discord/message.py index f6565ba1..5b4d79cb 100644 --- a/discord/message.py +++ b/discord/message.py @@ -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): -- cgit v1.2.3