You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Twitch userstate object, there's a few keys that contain dashes. These keys cannot be directly referenced in JavaScript because variables and object keys cannot contain the - char.
I propose refactoring the userstate object to use underscores where twitch uses dashes.
I know we can use them as userstate['user-id'], but that's not as clean as userstate.user_id
(Both styles could even be included)
This is probably more important now since Twitch has allowed users to change their usernames and we're about to come across the first batch of username releases.
if(userstate.user_id===someStoredUserID){// TODO: Do something if the user's id is the same as the stored id...}
I would also like to add a broadcaster: Boolean key to the userstate object, derived from the user's badges.
This would make it easier to tell if the user is a broadcaster or a moderator of the channel. It would also mean that you can also easily make commands broadcaster only and mod only without all the extra logic:
if(userstate.mod||userstate.broadcaster){// TODO: Allow access to function where the user needs to be a mod or broadcaster to use...}// ORif(userstate.broadcaster){// TODO: Allow access to function where the user needs to be the broadcaster to use...}
This is a bit of a long shot, but I'd be happy to add these changes and submit a PR myself, but to be honest, I don't really care if this is changed or not... I already have these changes implemented on my own program, it's more of a QoL change than anything else.
The text was updated successfully, but these errors were encountered:
I already do something similar to this @AlcaDesign. I just was suggesting that we could have TMI do this for us automatically without having to put in the refactoring code every time we use an event handler. Like I said, it's fine if nobody wants this included into the package.
In the Twitch userstate object, there's a few keys that contain dashes. These keys cannot be directly referenced in JavaScript because variables and object keys cannot contain the
-
char.I propose refactoring the userstate object to use underscores where twitch uses dashes.
I know we can use them as
userstate['user-id']
, but that's not as clean asuserstate.user_id
(Both styles could even be included)
This is probably more important now since Twitch has allowed users to change their usernames and we're about to come across the first batch of username releases.
I would also like to add a
broadcaster: Boolean
key to the userstate object, derived from the user's badges.This would make it easier to tell if the user is a broadcaster or a moderator of the channel. It would also mean that you can also easily make commands broadcaster only and mod only without all the extra logic:
This is a bit of a long shot, but I'd be happy to add these changes and submit a PR myself, but to be honest, I don't really care if this is changed or not... I already have these changes implemented on my own program, it's more of a QoL change than anything else.
The text was updated successfully, but these errors were encountered: