@@ -3361,7 +3361,7 @@ async def query_members(
3361
3361
self ,
3362
3362
query : str | None = None ,
3363
3363
* ,
3364
- limit : int = 5 ,
3364
+ limit : int | None = 5 ,
3365
3365
user_ids : list [int ] | None = None ,
3366
3366
presences : bool = False ,
3367
3367
cache : bool = True ,
@@ -3379,22 +3379,22 @@ async def query_members(
3379
3379
----------
3380
3380
query: Optional[:class:`str`]
3381
3381
The string that the username's start with.
3382
- limit: :class:`int`
3383
- The maximum number of members to send back. This must be
3384
- a number between 5 and 100.
3385
- presences: :class:`bool`
3382
+ user_ids: Optional[List[:class:`int`]]
3383
+ List of user IDs to search for. If the user ID is not in the guild then it won't be returned.
3384
+
3385
+ .. versionadded:: 1.4
3386
+ limit: Optional[:class:`int`]
3387
+ The maximum number of members to send back. If no query is passed, passing ``None`` returns all members.
3388
+ If a ``query`` or ``user_ids`` is passed, must be between 1 and 100. Defaults to 5.
3389
+ presences: Optional[:class:`bool`]
3386
3390
Whether to request for presences to be provided. This defaults
3387
3391
to ``False``.
3388
3392
3389
3393
.. versionadded:: 1.6
3390
3394
3391
3395
cache: :class:`bool`
3392
3396
Whether to cache the members internally. This makes operations
3393
- such as :meth:`get_member` work for those that matched.
3394
- user_ids: Optional[List[:class:`int`]]
3395
- List of user IDs to search for. If the user ID is not in the guild then it won't be returned.
3396
-
3397
- .. versionadded:: 1.4
3397
+ such as :meth:`get_member` work for those that matched. Defaults to ``True``.
3398
3398
3399
3399
Returns
3400
3400
-------
@@ -3414,20 +3414,25 @@ async def query_members(
3414
3414
if presences and not self ._state ._intents .presences :
3415
3415
raise ClientException ("Intents.presences must be enabled to use this." )
3416
3416
3417
- if query is None :
3418
- if query == "" :
3419
- raise ValueError ("Cannot pass empty query string." )
3417
+ if not limit or limit > 100 or limit < 1 :
3418
+ if query or user_ids :
3419
+ raise ValueError (
3420
+ "limit must be between 1 and 100 when using query or user_ids"
3421
+ )
3422
+ if not limit :
3423
+ query = ""
3424
+ limit = 0
3420
3425
3426
+ if query is None :
3421
3427
if user_ids is None :
3422
- raise ValueError ("Must pass either query or user_ids" )
3428
+ raise ValueError ("Must pass query or user_ids, or set limit to None " )
3423
3429
3424
3430
if user_ids is not None and query is not None :
3425
3431
raise ValueError ("Cannot pass both query and user_ids" )
3426
3432
3427
3433
if user_ids is not None and not user_ids :
3428
3434
raise ValueError ("user_ids must contain at least 1 value" )
3429
3435
3430
- limit = min (100 , limit or 5 )
3431
3436
return await self ._state .query_members (
3432
3437
self ,
3433
3438
query = query ,
0 commit comments