tmijs / tmi.js

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

Add channel join interval option #392

Closed AlcaDesign closed 4 years ago

AlcaDesign commented 4 years ago

Add option in the configuration to adjust the interval of the join rate. 2000ms is a safe default value but it could be faster. The actual rate limit is 50 JOINs per 15s which is every 300ms. The library is using a longer interval to avoid colliding with JOINs called from outside the queue.

https://github.com/tmijs/tmi.js/blob/92d7ccff8cecf33bc28c1f40612228e01943a4ff/lib/client.js#L177

This option should go in the options section of the configuration. The option should be named something short but specific like joinInterval. When the queue is created, the value should be validated that it can be parsed as a number, otherwise continue using the default 2000. It should be constrained to a minimum of 300.

const client = new tmi.Client({
    options: {
        joinInterval: 300
    }
});

Other improvements could be a smarter queue that detects the current JOIN rate to avoid clashing with joins called from outside the interval.