mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 22:32:50 +02:00
22.0.0
This commit is contained in:
+11
-13
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user