question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wiki isn't a Constructor

See original GitHub issue

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 ^^

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dijscommented, 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')...
0reactions
dijscommented, Jan 27, 2017

Great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Constructor (object-oriented programming) - Wikipedia
In class-based, object-oriented programming, a constructor (abbreviation: ctor) is a special type of subroutine called to create an object.
Read more >
Nullary constructor - Wikipedia
In computer programming, a nullary constructor is a constructor that takes no arguments. Also known as a 0-argument constructor or no-argument constructors.
Read more >
Constructor theory - Wikipedia
Constructor theory expresses physical laws exclusively in terms of which physical transformations, or tasks, are possible versus which are impossible, and why.
Read more >
Default constructor - Wikipedia
In computer programming languages, the term default constructor can refer to a constructor that is automatically generated by the compiler in the absence...
Read more >
List of Formula One constructors - Wikipedia
Constructors are awarded points based on the finishing position of each of their two drivers at each Grand Prix, and the constructor who...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found