diff options
| author | z03h <[email protected]> | 2021-03-24 05:17:34 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-24 08:17:34 -0400 |
| commit | fbb7ac6be144d9371c9a67735c80bb787d09673a (patch) | |
| tree | 491d5b71735857ab6f24dbe0caead6e136194794 | |
| parent | [commands] Include group args in command signature (diff) | |
| download | discord.py-fbb7ac6be144d9371c9a67735c80bb787d09673a.tar.xz discord.py-fbb7ac6be144d9371c9a67735c80bb787d09673a.zip | |
Add roles to guild.estimate_pruned_members
| -rw-r--r-- | discord/guild.py | 12 | ||||
| -rw-r--r-- | discord/http.py | 5 |
2 files changed, 14 insertions, 3 deletions
diff --git a/discord/guild.py b/discord/guild.py index 92d9a59e..9610cdea 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -1506,7 +1506,7 @@ class Guild(Hashable): data = await self._state.http.guild_webhooks(self.id) return [Webhook.from_state(d, state=self._state) for d in data] - async def estimate_pruned_members(self, *, days): + async def estimate_pruned_members(self, *, days, roles=None): """|coro| Similar to :meth:`prune_members` except instead of actually @@ -1517,6 +1517,11 @@ class Guild(Hashable): ----------- days: :class:`int` The number of days before counting as inactive. + roles: Optional[List[:class:`abc.Snowflake`]] + A list of :class:`abc.Snowflake` that represent roles to include in the estimate. If a member + has a role that is not specified, they'll be excluded. + + .. versionadded:: 1.7 Raises ------- @@ -1536,7 +1541,10 @@ class Guild(Hashable): if not isinstance(days, int): raise InvalidArgument('Expected int for ``days``, received {0.__class__.__name__} instead.'.format(days)) - data = await self._state.http.estimate_pruned_members(self.id, days) + if roles: + roles = [str(role.id) for role in roles] + + data = await self._state.http.estimate_pruned_members(self.id, days, roles) return data['pruned'] async def invites(self): diff --git a/discord/http.py b/discord/http.py index 43f01d75..5a5820bd 100644 --- a/discord/http.py +++ b/discord/http.py @@ -739,10 +739,13 @@ class HTTPClient: return self.request(Route('POST', '/guilds/{guild_id}/prune', guild_id=guild_id), json=payload, reason=reason) - def estimate_pruned_members(self, guild_id, days): + def estimate_pruned_members(self, guild_id, days, roles): params = { 'days': days } + if roles: + params['include_roles'] = ', '.join(roles) + return self.request(Route('GET', '/guilds/{guild_id}/prune', guild_id=guild_id), params=params) def get_all_custom_emojis(self, guild_id): |