snekfetch 4.0.0

This commit is contained in:
Daniel Odendahl Jr
2018-02-26 22:10:01 +00:00
parent a4767134e5
commit 9aaf21913b
22 changed files with 45 additions and 40 deletions
+3 -2
View File
@@ -66,13 +66,14 @@ module.exports = class GoogleFeudCommand extends Command {
}
async fetchSuggestions(question) {
const { text } = await snekfetch
const { raw } = await snekfetch
.get('https://suggestqueries.google.com/complete/search')
.query({
client: 'firefox',
q: question
});
const suggestions = JSON.parse(text)[1].filter(suggestion => suggestion.toLowerCase() !== question.toLowerCase());
const suggestions = JSON.parse(raw.toString())[1]
.filter(suggestion => suggestion.toLowerCase() !== question.toLowerCase());
if (!suggestions.length) return null;
return suggestions.map(suggestion => suggestion.toLowerCase().replace(question.toLowerCase(), '').trim());
}