How to use spotify-uri - 1 common examples

To help you get started, we’ve selected a few spotify-uri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RayzrDev / SharpBot / src / commands / Utility / spotify.js View on Github external
exports.run = async (bot, msg, args) => {
    if (args.length < 1) {
        throw 'You must specify a Spotify URI at least!';
    }

    const response = await got('https://spotify-auth.doxylamin.pw/', { json: true });

    if (response.body.success == true) {
        spotifyApi.setAccessToken(response.body.access_token);
    }

    const parsed = bot.utils.parseArgs(args, ['preview']);
    const spotifyUri = SpotifyUriParser.parse(parsed.leftover.join(' '));

    switch (spotifyUri.type) {
    case 'track':
        getTrackEmbed(msg, spotifyUri.id, parsed.options.preview);
        break;
    case 'artist':
        getArtistEmbed(msg, spotifyUri.id, parsed.options.preview);
        break;
    case 'playlist':
        getPlaylistEmbed(msg, spotifyUri.user, spotifyUri.id, parsed.options.preview);
        break;
    default:
        throw 'Sorry, I can\'t parse that type of URI yet.';
    }

};

spotify-uri

Parse the various Spotify URI formats into Objects and back

MIT
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis

Popular spotify-uri functions