aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGorialis <[email protected]>2017-08-02 08:10:28 +0900
committerRapptz <[email protected]>2017-08-08 17:31:08 -0400
commit1582116b72aba9d826c11487cf8c2ad31c6ac18e (patch)
treea4bc27f33b9739d8cff6c53ae640addcb65f3520 /docs
parentAdd operation documentation for VerificationLevel, ContentFilter (diff)
downloaddiscord.py-1582116b72aba9d826c11487cf8c2ad31c6ac18e.tar.xz
discord.py-1582116b72aba9d826c11487cf8c2ad31c6ac18e.zip
Add documentation examples for AsyncIterator and change_presence.
Diffstat (limited to 'docs')
-rw-r--r--docs/api.rst27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/api.rst b/docs/api.rst
index 96c9eeca..24347d00 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -1322,6 +1322,10 @@ Certain utilities make working with async iterators easier, detailed below.
Similar to :func:`utils.get` except run over the async iterator.
+ Getting the last message by a user named 'Dave' or ``None``: ::
+
+ msg = await channel.history().get(author__name='Dave')
+
.. comethod:: find(predicate)
|coro|
@@ -1331,6 +1335,13 @@ Certain utilities make working with async iterators easier, detailed below.
Unlike :func:`utils.find`\, the predicate provided can be a
coroutine.
+ Getting the last audit log with a reason or ``None``: ::
+
+ def predicate(event):
+ return event.reason is not None
+
+ event = await guild.audit_logs().find(predicate)
+
:param predicate: The predicate to use. Can be a coroutine.
:return: The first element that returns ``True`` for the predicate or ``None``.
@@ -1350,6 +1361,14 @@ Certain utilities make working with async iterators easier, detailed below.
every element it is iterating over. This function can either be a
regular function or a coroutine.
+ Creating a content iterator: ::
+
+ def transform(message):
+ return message.content
+
+ async for content in channel.history().map(transform):
+ message_length = len(content)
+
:param func: The function to call on every element. Could be a coroutine.
:return: An async iterator.
@@ -1359,6 +1378,14 @@ Certain utilities make working with async iterators easier, detailed below.
:class:`AsyncIterator` is returned that filters over the original
async iterator. This predicate can be a regular function or a coroutine.
+ Getting messages by non-bot accounts: ::
+
+ def predicate(message):
+ return not message.author.bot
+
+ async for elem in channel.history().filter(predicate):
+ ...
+
:param predicate: The predicate to call on every element. Could be a coroutine.
:return: An async iterator.