forked from venom59770/BOT-VENOM-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctionHelpers.js
32 lines (28 loc) · 952 Bytes
/
functionHelpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const google = require("./google.js");
fun = {
replyToMessageWith: function(replyMessage, message) {
message.reply(replyMessage);
}
}
exports.googleSearch = function(searchQuery, message) {
google.resultsPerPage = 3
var counter = 0
google(searchQuery, function(err, res) {
if (err)
console.error(err)
var link = res.links[counter];
console.log(link.title);
console.log(link.href);
fun.replyToMessageWith(link.title + ' - ' + link.href, message);
// Uncoment this line if you want the description of the web page
// fun.replyToMessageWith(link.description + "\n",message);
counter += 1
if (counter <= 2) {
// run the function again aka do the search again
res.next()
} else {
// else if counter if greater than 2 return. I dont want more google results
return;
}
});
}