如何使用 twitch 机器人让某人超时(client.timeout 和 client.say(channel, `/timeout @${tags.username} 不起作用)?

问题描述 投票:0回答:1

我无法使用 Twitch 聊天机器人禁止或超时在 js 中写入某些单词的用户。不过,我可以使用机器人发送消息。

我的代码:

client.on('message', async (channel, tags, message, self) => {
    if (self) return;

    console.log(`${tags['display-name']}: ${message}`);
    console.log(tags.username)



    const forbiddenWords = ['test1', 'test2', 'test3'];
    for (let i = 0, len = forbiddenWords.length; i < len; i++) {
        if(forbiddenWords[i] == message){
            const timeoutReason = `Explicit language: ${message}`;
            client.timeout(channel, tags.username, 10, timeoutReason);
            client.say(channel, `You got timeout for using explicit language! @${tags.username}`);
            console.log(`${tags.username} has been timeouted for: "${message}"!`);
          }
      }
});

我最近尝试创建一个 Twitch ChatBot,但遇到了禁止和超时的问题。我在 https://twitchapps.com/tmi/ 上创建了一个 oauth 令牌,但遇到权限问题或两种方法:

const timeoutReason = `Explicit language: ${message}`;
client.timeout(channel, tags.username, 1`your text`0, timeoutReason);
and:
/client.say(channel, `/timeout @${tags.username} 10
do not work anymore.

EEither the person who should be banned is not blocked or I get this error:
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: 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(). The promise rejected with the reason "No response from Twitch.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
javascript chatbot twitch
1个回答
0
投票

Twitch 将命令移至 API,您可以使用 tmi.js 投射的唯一命令是 /me。

https://discuss.dev.twitch.com/t/deprecation-of-chat-commands-through-irc/40486

© www.soinside.com 2019 - 2024. All rights reserved.