tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.54k stars 217 forks source link

non-existent user timeout #381

Closed LockDzn closed 4 years ago

LockDzn commented 4 years ago

Actual behaviour: When we try to time out a non-existent user, he returns No response from Twitch., after that if we try to time out again in an existing user he receives the timeout but returns the errorNo response from Twitch.

Expected behaviour: We try to timeout a user, if the user does not exist, it will return No response from Twitch., then if we try to timeout a user that exists, the timeout will be applied.

Error log:

timeout for usertest!
timeout could not be applied! Error: No response from Twitch.
timeout could not be applied! Error: No response from Twitch.

Server configuration

Code example:

const tmi = require('tmi.js');

const client = new tmi.Client({
    options: { debug: false },
    connection: { reconnect: true, secure: true },
    identity: { username: "xxx", password: "xxx" },
    channels: [ 'lockdzn']
});

client.connect();

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

    //if(channel == "#lockdzn"){
        let messageArray = message.split(" ");
        let user = messageArray[0].replace('@', '').toLowerCase();

        client.timeout(channel, user, 600).then((data) => {
            console.log(`timeout for ${user}!`);
        }).catch((err) => {
            console.log(`timeout could not be applied! Error: ${err}`);
        });
    //}
});