我正在为抽搐聊天创建一个带有节点的日志系统。当您键入“!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)
代码
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'
});