UNPKG

munar-adapter-uwave

Version:

üWave adapter for Munar

43 lines (34 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _DJBooth = require("./DJBooth"); var _mergeIncludedModels = _interopRequireDefault(require("./mergeIncludedModels")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } class DJHistory { constructor(uw) { this.uw = uw; } async getRecent(limit) { const booth = this.uw.getDJBooth(); // Skip the first entry if a song is currently being played, because that // entry will be the current song. const start = booth.getMedia() !== null ? 1 : 0; const query = { page: { offset: start, limit: limit } }; const { body } = await this.uw.request('get', 'booth/history', query); return (0, _mergeIncludedModels.default)(body).map(entry => ({ id: entry._id, media: (0, _DJBooth.normalizeMedia)(entry.media), user: this.uw.toBotUser(entry.user), playedAt: new Date(entry.playedAt) })); } } exports.default = DJHistory;