mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 08:44:10 +00:00
Add roles to guild.estimate_pruned_members
This commit is contained in:
parent
caa3b4e8f4
commit
fbb7ac6be1
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user