UNPKG

osu-api-extended

Version:

Advanced osu! api wrapper for v1 and v2, with extra stuff

59 lines 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.description = void 0; const request_1 = require("../../../../utility/request"); const request = (0, request_1.namespace)('https://osu.ppy.sh/api/v2/'); exports.description = { auth: 1, title: __filename, method: 'GET', description: 'Return list of events in order of creation time', params: [ { name: 'object', optional: true, params: [ { type: 'string', name: 'sort', optional: true, description: '\`\`\`id_desc\`\`\` or \`\`\`id_asc\`\`\`', }, { type: 'string', name: 'cursor_string', optional: true, description: 'Parameter for pagination', }, { type: 'string[]', name: 'type', optional: true, description: '\`\`\`achievement\`\`\` or \`\`\`beatmapPlaycount\`\`\` or \`\`\`beatmapsetApprove\`\`\` or \`\`\`beatmapsetDelete\`\`\` or \`\`\`beatmapsetRevive\`\`\` or \`\`\`beatmapsetUpdate\`\`\` or \`\`\`beatmapsetUpload\`\`\` or \`\`\`rank\`\`\` or \`\`\`userSupportAgain\`\`\` or \`\`\`userSupportFirst\`\`\` or \`\`\`userSupportGift\`\`\` or \`\`\`usernameChange\`\`\`', } ] }, ], return: 'response', }; const name = async (object) => { const params = {}; if (object?.sort) params.sort = object.sort; if (object?.cursor_string) params.cursor_string = object.cursor_string; const data = await request(`events`, { method: 'GET', params: params, }); if (object?.type != null) { if (!Array.isArray(object.type)) throw new Error('Event Type must be an Array of options'); const sorted = data.events.filter(r => object.type.includes(r.type)); data.events = sorted; } ; return data; }; exports.default = name; //# sourceMappingURL=events.js.map