Open tsanborn19-zz opened 7 years ago
Have same problem
The tutorial is from some time ago, and it uses slackbots, which apparently has gone through some changes lately.
In my case I'm using ES6 so I can take advantage of its proper classes support:
class JetaBot extends Bot {
constructor(settings) {
super(settings);
this.dbPath = settings.dbPath;
this.db = null;
}
run() {
super.on("start", this.onStart);
super.on("message", this.onMessage);
}
...
That does the trick I guess.
Any help for the below code still getting the same error?
// lib/bot.js
'use strict';
var util = require('util');
var path = require('path');
var fs = require('fs');
var SlackBot = require('slackbots');
class newBot extends SlackBot {
constructor(settings) {
super(settings);
}
run() {
super.on("start", this.onStart);
super.on("message", this.onMessage);
}
}
module.exports = newBot;
// in index.js
var newBot = require('./lib/bot');
const newbot = new newBot({
token: 'xx-xxx-xxx',
name: 'newBot',
});
Node Version : v9.5.0
Thanks for your time,
In following this tutorial (https://scotch.io/tutorials/building-a-slack-bot-with-node-js-and-chuck-norris-super-powers), I am attempting to inherit the bot using util to create my own. I am able to do this successfully when using version 0.3.0 of this library, but if I update to the current version, I get a "Constructor cannot be invoked without new" error.
Here is some of the code:
Do you happen to know the proper way to inherit the Bot class?