I can’t ban or timeout users with a Twitch chatbot who write certain words in js. However, I can send messages with the bot.
My code:
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}"!`);
}
}
});
I recently tried to create a Twitch ChatBot and ran into a problem with bans and timeouts. I created an oauth token on https://twitchapps.com/tmi/ but am having either permission issues or the two methods:
const timeoutReason = Explicit language: ${message}
;
client.timeout(channel, tags.username, 1your 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’
}