Last active
April 18, 2016 00:08
-
-
Save JonathanZWhite/f2beb1f67103df39f7c89b92084608a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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