Skip to content

Instantly share code, notes, and snippets.

@JonathanZWhite
Last active April 18, 2016 00:08
Show Gist options
  • Save JonathanZWhite/f2beb1f67103df39f7c89b92084608a2 to your computer and use it in GitHub Desktop.
Save JonathanZWhite/f2beb1f67103df39f7c89b92084608a2 to your computer and use it in GitHub Desktop.
class Music {
...
getRecommendation(message, bot) {
store.update(message.from, {
command: commands.GET_RECOMMENDATION,
spotify: {
numberOfRecs: message.text
}
})
const state = store.getState(message.from)
const selectedGenre = state.spotify.genre
const numberOfRecs = state.spotify.numberOfRecs
return MusicService.getRecommendation(selectedGenre, numberOfRecs)
.then(sendRecommendation)
function sendRecommendation(resp) {
if (!resp.length) return bot.sendMessage(message.from, 'Sorry, looks like I don\'t have anything for that category 🐣')
bot.sendMessage(message.from, 'Why not give this a listen 💃')
resp.forEach((song) => {
bot.sendMessage(message.from, song)
})
store.clearState()
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment