Source: components/ScoresComponent.js

  1. 'use strict';
  2. const Component = require('./Component')
  3. , ApiConstants = require('../Constants').API
  4. , BeatmapScore = require('../struct/BeatmapScore');
  5. /**
  6. * Scores-related API component
  7. * @memberof module:Components
  8. * @example
  9. * api.scores
  10. * .get('1110141')
  11. * .then(console.log);
  12. */
  13. class ScoresComponent extends Component {
  14. /**
  15. * Gets scores for a specific beatmap
  16. * @param {String} beatmapId The beatmap ID.
  17. * @param {Mods} [mods] The bitwise combination for the mods.
  18. * @param {Mode} [mode] The gamemode.
  19. * @param {Number} [limit] The limit of scores to get.
  20. * @param {String} [user] User to lookup.
  21. * @param {LookupType} [lookupType] Only for if user is given, the lookup mode for it.
  22. * @return {Promise<Object[]|BeatmapScore[]>} The object array from the API, or BeatmapScore object array if parsing is enabled.
  23. */
  24. get(beatmapId, mods, mode, limit, user, lookupType) {
  25. let options = { b: beatmapId };
  26. if (mods !== undefined)
  27. options.mods = mods;
  28. if (mode !== undefined)
  29. options.m = mode;
  30. if (limit !== undefined)
  31. options.limit = limit;
  32. if (user !== undefined)
  33. options.u = user;
  34. if (lookupType !== undefined)
  35. options.type = lookupType;
  36. return this.api.requester.get(ApiConstants.SCORES_GET, options, true, true, BeatmapScore);
  37. }
  38. }
  39. module.exports = ScoresComponent;