covilbot
Version:
Slack bot which connects with Mopidy and Spotify
30 lines (29 loc) • 866 B
JavaScript
module.exports = {
command: 'mode <mode> [enable]',
desc: 'Getting / Setting a specific mode state',
builder: {
mode: {
desc: 'The playback mode',
choices: ['consume', 'random', 'repeat', 'single']
},
enable: {
type: 'boolean',
desc: 'The enabled state of the mode'
}
},
handler: function (argv) {
var mode = argv.mode.charAt(0).toUpperCase() + argv.mode.slice(1)
if (argv.state) {
argv.db.logger.info('Setting %s mode to %s', argv.mode, argv.enable)
argv.db.mopidy.tracklist['set' + mode](argv.enable === 'true')
.done(function (value) {
argv.db.post(argv.db.attachments.mode(argv.mode, value))
})
} else {
argv.db.mopidy.tracklist['get' + mode]()
.done(function (value) {
argv.db.post(argv.db.attachments.mode(argv.mode, value))
})
}
}
}