-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
limit not working #4
Comments
Please post formatted code. It's really difficult to read as is. Thanks |
The code was formatted when I posted it. It was also inserted into the post via "Insert code". The best I can do to make it more view-able is put it in a text file. |
The best you can do is click on "Styling with Markdown ..." below the comment box and learn how to style comments on github. If you don't bother to do that don't expect me to bother considering your issue. |
I have had the same problem while coding my Discord bot.. it always returned 9 urls even though I had set my limit to 1. I was trying to fix it by making small changes in the node_modules/google-search-scraper/index.js and made it work by adding newResults.length = 1; to the file just before newResults.forEach(function(result) {
callback(null, result);
}); And then it respected the limit I set in my Discord bot code. |
I have tried the following piece of code
if(message.content.startsWith ("/google")) { var lastmsg = message var msgArray = message.content.split('/google ') var searchoptions = { query: msgArray[1], host: 'www.google.com.au', lang: 'en', limit: 1 }; var firstSearch = false; scraper.search(searchoptions, function(err, url) { //this is called for each result if(err) throw err; if(firstSearch == false) { console.log(url) message.channel.sendMessage(url).catch(console.error); firstSearch = true; } });
As you can see in that code i made a creative work-around.
But I shouldn't have had to do that, the problem is that even though i set limit to 1 it still didn't change it to 1.
I even thought maybe it's adding a zero on the end? making it 10 anyway? So i changed it to 01 but that didn't work either.
Is there something I'm doing wrong?
P.S.
Ignore the if statement about
message.content
and anything else about messages. That's there because i am using this inside of a discord bot.The text was updated successfully, but these errors were encountered: