Closed del0ss closed 4 years ago
Hello, I wanted my bot on command !joke from my database did not get an anecdote, but it gives an error: message.startsWith is not a function
const tmi = require('tmi.js') const mysql = require('mysql') const conn = mysql.createConnection({ host: "localhost", user: "twitch", database: "joke", password: "pass" }) conn.connect(function (err) { if (err) { return console.error("Error: " + err.message) } else { console.log("Connect MySQL") } }) let query="SELECT * FROM joke" conn.query(query, (err, result, field) =>{ console.log(err) let arr = result let rand = Math.floor(Math.random() * arr.length) const client = new tmi.Client({ options: { debug: true }, connection: { reconnect: true, secure: true }, identity: { username: 'streamcommunebot', password: ' ... ' }, channels: ['dummo'] }) client.connect() client.on('message', (channel, tags, message) => { if(message.toLowerCase() === '!joke') { client.say(channel, rand) } }) }) conn.end( err => { if (err) { console.log(err) return err } else { console.log('Database ----- Close') } })
Your message needs to be a string.
https://github.com/tmijs/tmi.js/blob/92d7ccff8cecf33bc28c1f40612228e01943a4ff/lib/commands.js#L359-L362
Hello, I wanted my bot on command !joke from my database did not get an anecdote, but it gives an error: message.startsWith is not a function