diff options
| author | Rapptz <[email protected]> | 2019-07-15 07:56:35 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-07-15 07:56:48 -0400 |
| commit | 5b2f630848f42940d62ce7af5ee1484a39259ceb (patch) | |
| tree | 81302fa9ad7c7282b9c0fb76b246a2b9772db2b9 /discord/guild.py | |
| parent | Allow complete disabling of the member cache. (diff) | |
| download | discord.py-5b2f630848f42940d62ce7af5ee1484a39259ceb.tar.xz discord.py-5b2f630848f42940d62ce7af5ee1484a39259ceb.zip | |
Add Guild.query_members to fetch members from the gateway.
Diffstat (limited to 'discord/guild.py')
| -rw-r--r-- | discord/guild.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py index 4c87e9f0..5a95f5da 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -1844,3 +1844,43 @@ class Guild(Hashable): data = await self._state.http.get_widget(self.id) return Widget(state=self._state, data=data) + + async def query_members(self, query, *, limit=5, cache=True): + """|coro| + + Request members that belong to this guild whose username starts with + the query given. + + This is a websocket operation and can be slow. + + .. warning:: + + Most bots do not need to use this. It's mainly a helper + for bots who have disabled ``guild_subscriptions``. + + .. versionadded:: 1.3 + + Parameters + ----------- + query: :class:`str` + The string that the username's start with. An empty string + requests all members. + limit: :class:`int` + The maximum number of members to send back. This must be + a number between 1 and 1000. + cache: :class:`bool` + Whether to cache the members internally. This makes operations + such as :meth:`get_member` work for those that matched. + + Raises + ------- + asyncio.TimeoutError + The query timed out waiting for the members. + + Returns + -------- + List[:class:`Member`] + The list of members that have matched the query. + """ + limit = limit or 5 + return await self._state.query_members(self, query=query, limit=limit, cache=cache) |