-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #832 from Regalijan/master
Add searchUsers method
- Loading branch information
Showing
5 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Includes | ||
const getPageResults = require('../util/getPageResults.js').func | ||
|
||
// Args | ||
exports.required = ['keyword'] | ||
exports.optional = ['limit', 'cursor', 'jar'] | ||
|
||
// Docs | ||
/** | ||
* ✅ Gets a list of users matching the keyword | ||
* @category User | ||
* @alias searchUsers | ||
* @param {string} keyword - The search term to use | ||
* @param {10 | 25 | 50 | 100} limit - The maximum number of matching users to return | ||
* @param {string} cursor - The cursor to use when fetching the next or previous page | ||
* @returns {Promise<UserSearchResult[]>} | ||
* @example const noblox = require("noblox.js") | ||
* noblox.searchUsers("bob", 10, "cursorstring") | ||
**/ | ||
|
||
// Define | ||
function searchUsers (jar, keyword, limit, cursor) { | ||
return getPageResults({ | ||
url: '//users.roblox.com/v1/users/search', | ||
jar, | ||
limit, | ||
pageCursor: cursor, | ||
query: { | ||
keyword | ||
} | ||
}) | ||
} | ||
|
||
exports.func = function (args) { | ||
return searchUsers( | ||
args.jar, | ||
args.keyword, | ||
args.limit ?? 10, | ||
args.cursor | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters