我正在创建一个带有节点的日志系统来进行抽搐聊天。键入"!logs user"它应该将正确的user.txt文件上传到pastebin并在聊天中给出一个指向pastebin的链接。
我使用的是pastebin-js和tmi.js
问题是当我键入!logs user时它在控制台中发出错误
C:\gempbot\node_modules\pastebin-js\bin\pastebin.js:137
this.createPaste(data, title, format, privacy, expiration)
^
TypeError: Cannot read property 'createPaste' of undefined
at C:\gempbot\node_modules\pastebin-js\bin\pastebin.js:137:13
at fs.js:334:14
at FSReqWrap.oncomplete (fs.js:95:15)
CODE
client.on('chat', function (channel, user, message, self) {
if (user["username"] === admins[0] || user["username"] === admins[1] || user["user-type"] === "mod" ) {
if ( message.indexOf("!logs") >= 0 ) {
var getNthWord = function(string, n){
var words = string.split(" ");
return words[n-1];
}
pastebin.createPasteFromFile('./logs/' + getNthWord(message, 2) + '.txt', 'logs for ' + getNthWord(message, 2))
.then(function (data) {
// we have succesfully pasted it. Data contains the id
console.log(data);
client.say(channel, 'Logs for ' + getNthWord(message, 2) + 'http://pastebin.com/' + data);
})
.fail(function (err) {
console.log(err);
});
}
}
});
有没有人有一个想法如何解决此错误?我对实际导致问题的原因感到困惑。 这里是在pastebin中验证的其余代码(在我的代码的顶部)
var PastebinAPI = require('pastebin-js'),
pastebin = new PastebinAPI({
'api_dev_key' : 'censored',
'api_user_name' : 'censored',
'api_user_password' : 'censored'
});