aboutsummaryrefslogtreecommitdiff
path: root/discord/guild.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-14 17:26:18 -0400
committerRapptz <[email protected]>2019-04-14 17:33:57 -0400
commit519f0c07eada6a37252252fafd64bb27f4a3125b (patch)
tree3dba9594ba1efc3dd591c6b4a0d4be5a4fe808e2 /discord/guild.py
parent[commands] Use message creation as the reference time in cooldowns (diff)
downloaddiscord.py-519f0c07eada6a37252252fafd64bb27f4a3125b.tar.xz
discord.py-519f0c07eada6a37252252fafd64bb27f4a3125b.zip
Add compute_prune_count to Guild.prune_members
Fix #2085
Diffstat (limited to 'discord/guild.py')
-rw-r--r--discord/guild.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 52982856..2126bb3c 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -1021,8 +1021,8 @@ class Guild(Hashable):
reason=e['reason'])
for e in data]
- async def prune_members(self, *, days, reason=None):
- """|coro|
+ async def prune_members(self, *, days, compute_prune_count=True, reason=None):
+ r"""|coro|
Prunes the guild from its inactive members.
@@ -1041,6 +1041,11 @@ class Guild(Hashable):
The number of days before counting as inactive.
reason: Optional[:class:`str`]
The reason for doing this action. Shows up on the audit log.
+ compute_prune_count: :class:`bool`
+ Whether to compute the prune count. This defaults to ``True``
+ which makes it prone to timeouts in very large guilds. In order
+ to prevent timeouts, you must set this to ``False``. If this is
+ set to ``False``\, then this function will always return ``None``.
Raises
-------
@@ -1053,14 +1058,15 @@ class Guild(Hashable):
Returns
---------
- :class:`int`
- The number of members pruned.
+ Optional[:class:`int`]
+ The number of members pruned. If ``compute_prune_count`` is ``False``
+ then this returns ``None``.
"""
if not isinstance(days, int):
raise InvalidArgument('Expected int for ``days``, received {0.__class__.__name__} instead.'.format(days))
- data = await self._state.http.prune_members(self.id, days, reason=reason)
+ data = await self._state.http.prune_members(self.id, days, compute_prune_count=compute_prune_count, reason=reason)
return data['pruned']
async def webhooks(self):