You should really write a real IRC and IRCv3 tags parser that splits messages based on the protocol.
For example you have this to check for a resub message:
if (message.indexOf('user-type= :tmi.twitch.tv USERNOTICE') >= 0) {
What if the user-type
tag isn’t empty? What is there is another tag added behind it or the order of the tags is different? What if a user simply sends a regular chat message that contains that string? Sure, that last one is unlikely, but it can still happen. The issue with doing it like this is that it can break really easily.
The same applies for how you read the tags. It is not guaranteed that for example login
will always stay the 5th tag. It is also mentioned in the IRCv3 tags spec that the order of tags must not matter.
Writing a very basic IRC parser isn’t hard, or maybe there even are libraries for that already you can use. Is that JavaScript?