Change in the way Requests work

This commit is contained in:
Daniel Odendahl Jr
2017-04-03 20:38:18 +00:00
parent 0d05032bb3
commit 06e1cd9c50
18 changed files with 213 additions and 118 deletions
+7 -2
View File
@@ -27,11 +27,16 @@ module.exports = class ImageSearchCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let thingToSearch = encodeURI(args.query);
let thingToSearch = args.query;
let searchMsg = await message.say('Searching...');
try {
let response = await request
.get(`https://www.google.com/search?tbm=isch&gs_l=img&q=${thingToSearch}`);
.get('https://www.google.com/search')
.query({
tbm: 'isch',
gs_1: 'img',
q: thingToSearch
});
const $ = cheerio.load(response.text);
const result = $('.images_table').find('img').first().attr('src');
return searchMsg.edit(result);