Skip to content
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

Wiki isn't a Constructor #32

Closed
Carbowix opened this issue Jan 22, 2017 · 5 comments
Closed

Wiki isn't a Constructor #32

Carbowix opened this issue Jan 22, 2017 · 5 comments

Comments

@Carbowix
Copy link

I was trying to build a bot that gets from wiki a simple summary about the User Search.

Everything is good, but gives a error saying Wiki isnt Constructor. Whats that?.

{ var Wiki = require('wikijs'); var term = args.join(' '); if (!term) { msg.channel.sendMessage("Please Enter a Term to Search for it in the Wiki."); return; } msg.channel.sendMessage(":mag_right: Searching for your Term..").then(m => { new Wiki().search(term, 1).then(function(data) { new Wiki().page(data.results[0]).then(function(page) { page.summary().then(function(summary) { var sumText = summary.toString().split('\n'); var continuation = function() { var paragraph = sumText.shift(); msg.channel.sendMessage(paragraph); console.log(paragraph); console.log(sumText); if (paragraph) { m.edit(paragraph); msg.channel.sendMessage(paragraph); msg.channel.sendMessage(sumText); } msg.channel.sendMessage(paragraph); }; continuation(); }); }); }, function(err) { m.edit(err); }); }) };

Thank you if you helped ^^

@dijs
Copy link
Owner

dijs commented Jan 23, 2017

Try converting all the new Wiki()'s to Wiki().

Wiki is not a class anymore. It is a function which returns an object with other functions.

Also, to help remember this, I normally would use lower case when using and requiring.

var wiki = require('wikijs');
wiki().search('hello')...

@Carbowix
Copy link
Author

Did what you told me, but now it says wiki isn't a function ._.

var wiki = require('wikijs'); var term = args.join(' '); if (!term) { msg.channel.sendMessage("Please Enter a Term to Search for it in the Wiki."); return; } msg.channel.sendMessage(":mag_right: Searching for your Term..").then(m => { wiki().search(term, 1).then(function(data) { wiki().page(data.results[0]).then(function(page) { page.summary().then(function(summary) { var sumText = summary.toString().split('\n'); var continuation = function() { var paragraph = sumText.shift(); if (paragraph) { m.edit(paragraph); msg.channel.sendMessage(paragraph); } }; continuation(); }); }); }, function(err) { m.edit(err); }); })
Weird though. I wonder whats wrong ;c

@dijs
Copy link
Owner

dijs commented Jan 25, 2017

Try var wiki = require('wikijs').default;

@Carbowix
Copy link
Author

Thanks it worked Finally :D

@dijs
Copy link
Owner

dijs commented Jan 27, 2017

Great!

@dijs dijs closed this as completed Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants