mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Add Messageable.ack
This commit is contained in:
parent
f7524c9919
commit
8daf411c72
@ -776,3 +776,25 @@ class Messageable(metaclass=abc.ABCMeta):
|
||||
counter += 1
|
||||
"""
|
||||
return HistoryIterator(self, limit=limit, before=before, after=after, around=around, reverse=reverse)
|
||||
|
||||
@asyncio.coroutine
|
||||
def ack(self):
|
||||
"""|coro|
|
||||
|
||||
Marks this channel 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.')
|
||||
channel = yield from self._get_channel()
|
||||
yield from state.http.ack_channel(channel.id)
|
||||
|
@ -329,6 +329,12 @@ class HTTPClient:
|
||||
data = yield from self.request(r, json={'token': self._ack_token})
|
||||
self._ack_token = data['token']
|
||||
|
||||
@asyncio.coroutine
|
||||
def ack_channel(self, channel_id):
|
||||
r = Route('POST', '/channels/{channel_id}/ack', channel_id=channel_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))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user