Yo I'm trying to get TwitchBot's Twitch integration working via twitch-commando
but keep getting this error:
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)
So basically I'm trying to figure out how to get it to show me what the undefined
part is. I've been going back and forth trying multiple different logging methods but nothing seems to have helped at all. Any help would be much appreciated.
Here is my index.js
code:
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);
And here is my package.json
with all of our Dependencies listed:
{
"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"
}
}
This is the .eslintrc.json
file I am using:
{
"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"
}
}
Would be more than grateful if someone could point me in the right direction.
Note:
As pointed out below there is a typo in client.registerDetaultCommands();
. However, it seems that typo is unfortunately on the twitch-commando
side as changing it to client.registerDefaultCommands();
breaks the flag.
question from:
https://stackoverflow.com/questions/65853062/twitch-commando-error-cannot-read-property-get-of-undefined