Hi there, I’m trying to use my own account to moderate a Twitch chat with tmi.js, but it seems impossible. I can successfully connect and receive messages from the chat, but I can’t delete a message or time out someone. I get the error: No response from Twitch.
directly.
I obtained the OAuth password using this site. I also tried to connect with a token from my application and received it on localhost, but the result was the same.
Additionally, I attempted to connect my bot to another account, and I encountered the same error.
I’m sure to be moderator in the targeted channel, and I’ve also tried with my own channel.
I’m pretty certain that I’m using the correct scopes without missing any. Here are the scopes I used: moderation:read+moderator:manage:banned_users+moderator:manage:chat_messages+channel:bot+channel:moderate+chat:edit+chat:read+user:bot+user:read:chat+user:write:chat
Here is my code:
const tmi = require('tmi.js');
const client = new tmi.client({ identity: { username: 'azeriius', password: 'oauth:XXX' }, channels: ['azeriius'] });
client.connect();
client.on('message', (channel, states, message, isSelf) => {
if (message === 'test') {
// DELETE MESSAGE
client.deletemessage(channel, states.id).then(data => {
console.log(data);
}).catch(err => {
console.log(err);
})
// TIMEOUT
client.timeout(channel, states.username, 300, 'Test').then(data => {
console.log(data);
}).catch(err => {
console.log(err);
})
}
});
client.on('connected', () => {
console.log('Connected');
})
I also tried to get more information with the event raw_message
, and I received this response: @msg-id=unrecognized_cmd :tmi.twitch.tv NOTICE #azeriius :Unrecognized command: /timeout
Someone has an idea please?