So I started to make a twitch chatbot. It has a really basic script from a tutorial(https://www.youtube.com/watch?v=ijl3GUHvKIw) but, when I try to send messages with the bot I got this error:
(node:10688) UnhandledPromiseRejectionWarning: Cannot send anonymous messages.
(node:10688) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Can somebody help me how to fix this? (I just started code in js so I don't know a lot about it)
EDIT: Here is my code:
const tmi = require('tmi.js');
const option = {
options: {
debug: true,
},
connection: {
cluster: 'aws',
reconnect: true,
},
indentity: {
username: 'xxxxxx',
password: 'oauth:xxxxxxxxxxxxxxxxx'
},
channels: ['ady_studios'],
};
const client = new tmi.client(option);
client.connect();
client.on('connected', (adress, port) => {
client.action('Ady Studios is online!');
});
client.on('chat', (channel, user, message, self) => {
if (message === '!game') {
client.action('No. its not play time.');
}
});
You have a typo in option
object, instead of option.indentity
should be option.identity
. Try with
const tmi = require("tmi.js");
const option = {
options: {
debug: true
},
connection: {
cluster: "aws",
reconnect: true
},
// you have a typo here, indentity idenity
// so tmi is defaulting to join channel as anonymous user
// indentity: {
// username: "xxxxxx",
// password: "oauth:xxxxxxxxxxxxxxxxx"
// },
identity: {
username: "xxxxxx",
password: "oauth:xxxxxxxxxxxxxxxxx"
},
channels: ["ady_studios"]
};
const client = new tmi.client(option);
client.connect();
client.on("connected", (adress, port) => {
client.action("Ady Studios is online!");
});
client.on("chat", (channel, user, message, self) => {
if (message === "!game") {
client.action("No. its not play time.");
}
});
Remember to put your actual username and password