Add support for message acking.
This commit is contained in:
		@@ -36,7 +36,7 @@ from .emoji import Emoji
 | 
			
		||||
from .game import Game
 | 
			
		||||
from .permissions import PermissionOverwrite
 | 
			
		||||
from .colour import Colour
 | 
			
		||||
from .errors import InvalidArgument
 | 
			
		||||
from .errors import InvalidArgument, ClientException
 | 
			
		||||
from .channel import *
 | 
			
		||||
from .enums import GuildRegion, Status, ChannelType, try_enum, VerificationLevel
 | 
			
		||||
from .mixins import Hashable
 | 
			
		||||
@@ -979,3 +979,23 @@ class Guild(Hashable):
 | 
			
		||||
            Unbanning failed.
 | 
			
		||||
        """
 | 
			
		||||
        yield from self._state.http.unban(user.id, self.id)
 | 
			
		||||
 | 
			
		||||
    def ack(self):
 | 
			
		||||
        """|coro|
 | 
			
		||||
 | 
			
		||||
        Marks every message in this guild as read.
 | 
			
		||||
 | 
			
		||||
        The user must not be a bot user.
 | 
			
		||||
 | 
			
		||||
        Raises
 | 
			
		||||
        -------
 | 
			
		||||
        HTTPException
 | 
			
		||||
            Acking failed.
 | 
			
		||||
        ClientException
 | 
			
		||||
            You must not be a bot user.
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        state = self._state
 | 
			
		||||
        if state.is_bot:
 | 
			
		||||
            raise ClientException('Must not be a bot account to ack messages.')
 | 
			
		||||
        return state.http.ack_guild(self.id)
 | 
			
		||||
 
 | 
			
		||||
@@ -227,6 +227,7 @@ class HTTPClient:
 | 
			
		||||
    def _token(self, token, *, bot=True):
 | 
			
		||||
        self.token = token
 | 
			
		||||
        self.bot_token = bot
 | 
			
		||||
        self._ack_token = None
 | 
			
		||||
 | 
			
		||||
    # login management
 | 
			
		||||
 | 
			
		||||
@@ -321,6 +322,16 @@ class HTTPClient:
 | 
			
		||||
 | 
			
		||||
        return self.request(r, data=form)
 | 
			
		||||
 | 
			
		||||
    @asyncio.coroutine
 | 
			
		||||
    def ack_message(self, channel_id, message_id):
 | 
			
		||||
        r = Route('POST', '/channels/{channel_id}/messages/{message_id}/ack', channel_id=channel_id,
 | 
			
		||||
                                                                          message_id=message_id)
 | 
			
		||||
        data = yield from self.request(r, json={'token': self._ack_token})
 | 
			
		||||
        self._ack_token = data['token']
 | 
			
		||||
 | 
			
		||||
    def ack_guild(self, guild_id):
 | 
			
		||||
        return self.request(Route('POST', '/guilds/{guild_id}/ack', guild_id=guild_id))
 | 
			
		||||
 | 
			
		||||
    def delete_message(self, channel_id, message_id):
 | 
			
		||||
        r = Route('DELETE', '/channels/{channel_id}/messages/{message_id}', channel_id=channel_id,
 | 
			
		||||
                                                                            message_id=message_id)
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ from .emoji import Emoji
 | 
			
		||||
from .object import Object
 | 
			
		||||
from .calls import CallMessage
 | 
			
		||||
from .enums import MessageType, try_enum
 | 
			
		||||
from .errors import InvalidArgument
 | 
			
		||||
from .errors import InvalidArgument, ClientException
 | 
			
		||||
from .embeds import Embed
 | 
			
		||||
 | 
			
		||||
class Message:
 | 
			
		||||
@@ -576,3 +576,23 @@ class Message:
 | 
			
		||||
            You do not have the proper permissions to remove all the reactions.
 | 
			
		||||
        """
 | 
			
		||||
        yield from self._state.http.clear_reactions(self.id, self.channel.id)
 | 
			
		||||
 | 
			
		||||
    def ack(self):
 | 
			
		||||
        """|coro|
 | 
			
		||||
 | 
			
		||||
        Marks this message as read.
 | 
			
		||||
 | 
			
		||||
        The user must not be a bot user.
 | 
			
		||||
 | 
			
		||||
        Raises
 | 
			
		||||
        -------
 | 
			
		||||
        HTTPException
 | 
			
		||||
            Acking failed.
 | 
			
		||||
        ClientException
 | 
			
		||||
            You must not be a bot user.
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        state = self._state
 | 
			
		||||
        if state.is_bot:
 | 
			
		||||
            raise ClientException('Must not be a bot account to ack messages.')
 | 
			
		||||
        return state.http.ack_message(self.channel.id, self.id)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user