lunify.js
Version:
A basic api wrapper for the spotify api covering the oauth routes.
31 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserPlaylistsManager = void 0;
const playlist_1 = require("../../structures/playlist");
const cache_1 = require("../cache");
class UserPlaylistsManager {
client;
user;
cache;
constructor(client, user) {
this.client = client;
this.user = user;
this.cache = new cache_1.CacheManager();
}
async fetch(page) {
const params = new URLSearchParams();
params.append("limit", "50");
params.append("offset", ((page || 0) * 50).toString() || "0");
const res = await this.client.rest.get(`/me/playlists?${params.toString()}`, {
headers: {
Authorization: await this.user.oauth.getAuthorization()
}
});
const playlists = res.items.map((playlist) => new playlist_1.PartialPlaylist(this.client, playlist, this.user.oauth));
for (const playlist of playlists)
this.cache.set(playlist.id, playlist);
return playlists;
}
}
exports.UserPlaylistsManager = UserPlaylistsManager;
//# sourceMappingURL=Playlists.js.map