Js 抽搐机器人 "Cannot send anonymous messages."

Js twitch bot "Cannot send anonymous messages."

所以我开始制作一个 twitch 聊天机器人。它有一个来自教程 (https://www.youtube.com/watch?v=ijl3GUHvKIw) 的非常基本的脚本,但是,当我尝试使用机器人发送消息时,我收到了这个错误:

(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)

有人可以帮我解决这个问题吗? (我刚开始用js写代码所以不太懂)

编辑:这是我的代码:

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.');
  }
    });

您在 option 对象中有一个拼写错误,而不是 option.indentity 应该是 option.identity。试试

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.");
  }
});

记得输入你的真实用户名和密码