哟,我正在尝试通过 TwitchBot 的 Twitch 集成工作,twitch-commando
但不断收到此错误:
info: Register command system:eval
info: Register command system:help
info: Register command system:join
info: Register command system:part
info: Register command system:prefix
info: Register command admin:broadcast
info: Register command admin:create-channel
info: Register command mod:announce
info: Register command util:channel
info: Register command util:say
info: Register command util:user-info
info: Loading global emotes
info: Current default prefix is !
info: Connecting to Twitch Chat
TypeError: Cannot read property 'get' of undefined
at TwitchCommandoClient.connect (/home/mountaint-dev/TwitchBot/node_modules/twitch-commando/src/client/TwitchCommandoClient.js:133:60)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
所以基本上我想弄清楚如何让它向我展示这undefined
部分是什么。我一直在尝试多种不同的日志记录方法,但似乎没有任何帮助。任何帮助将非常感激。
这是我的index.js
代码:
const { TwitchCommandoClient, TwitchChatUser, TwitchChatMessage, CommandoSQLiteProvider } = require('twitch-commando');
const eslint = require('eslint');
const sqlite = require('sqlite');
const path = require('path');
require('dotenv').config();
const fs = require('fs');
const TOKEN = process.env.CLIENT_TOKEN;
const env1 = process.env.OWNER_1;
const env2 = process.env.OWNER_2;
var client = new TwitchCommandoClient({
username: 'TwitchBot',
commandPrefix: '!',
oauth: '',
channels: '',
botOwners: [env1, env2],
disableEveryone: true,
unknownCommandResponse: false
});
client.enableVerboseLogging();
client.setProvider(sqlite.open(path.join(__dirname, 'database')).then(db => new CommandoSQLiteProvider(db))
);
client.registerDetaultCommands();
client.registerCommandsIn(path.join(__dirname, 'commands'));
client.on("ready", function () {
console.log(`the client becomes ready to start`);
console.log(`I am ready! Logged in as ${client.user.tag}!`);
console.log(`Bot has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
client.user.setActivity("the upright organ");
client.generateInvite(['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'])
.then(link => {
console.log(`Generated bot invite link: ${link}`);
inviteLink = link;
});
});
client.on("reconnecting", function () {
console.log(`client tries to reconnect to the WebSocket`);
});
client.on("resume", function (replayed) {
console.log(`whenever a WebSocket resumes, ${replayed} replays`);
});
client.on("warn", function (info) {
console.log(`warn: ${info}`);
});
client.on("debug", function (info) {
console.log(`debug -> ${info}`);
});
client.on("error", function (error) {
console.error(`client's WebSocket encountered a connection error: ${error}`);
});
client.on("message", function (message) {
console.log(`message is created -> ${message}`);
});
client.connect(TOKEN).catch(console.error);
这是我package.json
列出的所有依赖项:
{
"name": "twitchbot",
"version": "1.1.0",
"description": "Twitch Integration bot built using Discord.js Commando and Twitch API",
"author": "Discord Coding Community <https://github.com/Discord-Coding-Community>",
"repository": {
"type": "git",
"url": "https://github.com/Discord-Coding-Community/TwitchBot"
},
"keywords": [
"twitch",
"bot",
"chatbot",
"chat",
"commando"
],
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"main": "index.js",
"dependencies": {
"better-queue": "^3.8.10",
"common-tags": "^1.8.0",
"discord.js": "^12.5.1",
"discord.js-commando": "^0.11.1",
"enmap": "5.8.4",
"dotenv": "^8.2.0",
"eslint": "^7.18.0",
"express": "^4.17.1",
"loader": "^2.1.1",
"node-fetch": "^2.6.0",
"recursive-readdir-sync": "^1.0.6",
"recursive-readdir-synchronous": "0.0.4",
"sleep": "^6.1.0",
"sqlite": "^4.0.19",
"tmi.js": "^1.5.0",
"twitch-commando": "^1.0.12",
"winston": "^3.2.1",
"discord-error-handler": "^1.1.6",
"discord.js-light": "^3.5.0"
},
"devDependencies": {
"clean-documentation-theme": "^0.5.2",
"jsdoc": "^3.6.3",
"nodemon": "^2.0.7"
},
"engines": {
"node": "^12.0.0"
}
}
这是.eslintrc.json
我正在使用的文件:
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2019
},
"rules": {
"brace-style": [
"error",
"stroustrup",
{
"allowSingleLine": true
}
],
"comma-dangle": [
"error",
"always-multiline"
],
"comma-spacing": "error",
"comma-style": "error",
"curly": [
"error",
"multi-line",
"consistent"
],
"dot-location": [
"error",
"property"
],
"handle-callback-err": "off",
"indent": [
"error",
"tab"
],
"max-nested-callbacks": [
"error",
{
"max": 4
}
],
"max-statements-per-line": [
"error",
{
"max": 2
}
],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 2,
"maxEOF": 1,
"maxBOF": 0
}
],
"no-shadow": [
"error",
{
"allow": [
"err",
"resolve",
"reject"
]
}
],
"no-trailing-spaces": [
"error"
],
"no-var": "error",
"object-curly-spacing": [
"error",
"always"
],
"prefer-const": "error",
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"yoda": "error"
}
}
如果有人能指出我正确的方向,将不胜感激。
注意:
正如下面所指出的,在client.registerDetaultCommands();
. 但是,不幸的是,拼写错误似乎在twitch-commando
一边,因为将其更改为client.registerDefaultCommands();
破坏标志。