diff --git a/discord/abc.py b/discord/abc.py index 785b81ffb..8d479b948 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -335,7 +335,6 @@ class GuildChannel: - Guild roles - Channel overrides - Member overrides - - Whether the channel is the default channel. Parameters ---------- @@ -764,7 +763,7 @@ class Messageable(metaclass=abc.ABCMeta): Example Usage: :: - with channel.typing(): + async with channel.typing(): # do expensive stuff here await channel.send('done!') diff --git a/discord/client.py b/discord/client.py index 91eff60ca..25fd5bb78 100644 --- a/discord/client.py +++ b/discord/client.py @@ -753,6 +753,11 @@ class Client: The game parameter is a Game object (not a string) that represents a game being played currently. + Example: :: + + game = discord.Game(name="with the API") + await client.change_presence(status=discord.Status.idle, game=game) + Parameters ---------- game: Optional[:class:`Game`] diff --git a/docs/api.rst b/docs/api.rst index 96c9eeca7..24347d00d 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.