aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-06-15 04:46:19 -0400
committerRapptz <[email protected]>2016-06-15 04:46:19 -0400
commit7c760d32713db5128f95ae9699a32458a0cf25f4 (patch)
tree2d923d69c7643997c30bfa1838740c40f57483fd
parentMake sure the socket is closed when we call VoiceClient.disconnect (diff)
downloaddiscord.py-7c760d32713db5128f95ae9699a32458a0cf25f4.tar.xz
discord.py-7c760d32713db5128f95ae9699a32458a0cf25f4.zip
Add Client.get_message
-rw-r--r--discord/client.py34
-rw-r--r--discord/http.py3
2 files changed, 37 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py
index 20887342..d7767180 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -1077,6 +1077,40 @@ class Client:
data = yield from self.http.edit_message(message.id, channel.id, content, guild_id=guild_id)
return Message(channel=channel, **data)
+ @asyncio.coroutine
+ def get_message(self, channel, id):
+ """|coro|
+
+ Retrieves a single :class:`Message` from a :class:`Channel`.
+
+ This can only be used by bot accounts.
+
+ Parameters
+ ------------
+ channel: :class:`Channel`
+ The text channel to retrieve the message from.
+ id: str
+ The message ID to look for.
+
+ Returns
+ --------
+ :class:`Message`
+ The message asked for.
+
+ Raises
+ --------
+ NotFound
+ The specified channel or message was not found.
+ Forbidden
+ You do not have the permissions required to get a message.
+ HTTPException
+ Retrieving the message failed.
+ """
+
+ data = yield from self.http.get_message(channel.id, id)
+ return Message(channel=channel, **data)
+
+
def _logs_from(self, channel, limit=100, before=None, after=None):
"""|coro|
diff --git a/discord/http.py b/discord/http.py
index 9cd46bad..584b2f07 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -262,6 +262,9 @@ class HTTPClient:
}
return self.patch(url, json=payload, bucket='messages:' + str(guild_id))
+ def get_message(self, channel_id, message_id):
+ url = '{0.CHANNELS}/{1}/messages/{2}'.format(self, channel_id, message_id)
+ return self.get(url, bucket=_func_())
def logs_from(self, channel_id, limit, before=None, after=None):
url = '{0.CHANNELS}/{1}/messages'.format(self, channel_id)