This commit is contained in:
Daniel Odendahl Jr
2017-06-01 08:44:02 +00:00
parent 7802bb49cb
commit 14f85f94bd
129 changed files with 1915 additions and 1720 deletions
+11 -13
View File
@@ -23,19 +23,17 @@ module.exports = class GoogleCommand extends Command {
async run(msg, args) {
const { query } = args;
const message = await msg.say('Searching...');
try {
const { text } = await snekfetch
.get('https://www.google.com/search')
.query({
q: query
});
const $ = cheerio.load(text);
let href = $('.r').first().find('a').first().attr('href');
if (!href) throw new Error('No Results.');
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
} catch (err) {
return message.edit(`${err.name}: ${err.message}`);
const { text } = await snekfetch
.get('https://www.google.com/search')
.query({
q: query
});
const $ = cheerio.load(text);
let href = $('.r').first().find('a').first().attr('href');
if (!href) {
return msg.say('No Results.');
}
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
}
};