const { spotify} = require('../utilities/spotify') exports.command = 'shuffle' exports.handler = argv => argv .option('on', { type: 'boolean', description: 'Enables shuffle', }) .option('off', { type: 'boolean', description: 'Disables shuffle', }) exports.handler = async ({ on, off }) => { try { let state; if (!on && !off) { const { body } = await spotify.getMyCurrentPlaybackState(); const { shuffle_state } = body state = !shuffle_state; // toggle state } switch (true) { case on: state = true; break; case off: state = false; break; } await spotify.ensure(); await spotify.setShuffle(state); } catch (e) { console.error(e.message); } };