aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/guild.py22
-rw-r--r--discord/http.py11
-rw-r--r--discord/message.py22
3 files changed, 53 insertions, 2 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 878ceb03..760632bc 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -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)
diff --git a/discord/http.py b/discord/http.py
index baa9a749..29f4fdfc 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -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)
diff --git a/discord/message.py b/discord/message.py
index 7c809d9f..cec7647e 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -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)