emiliobool / node-red-contrib-twitch-chat

tmi.js wrapper nodes for Node Red
Apache License 2.0
9 stars 2 forks source link

Rewards #22

Closed diegozalez closed 1 year ago

diegozalez commented 1 year ago

I'm trying to implement rewards using bits but I can't make it work, does anyone know how to do this?

emiliobool commented 1 year ago

If you want to have them click a button or something like that and make them get a reward using bits, the only way is making/finding a twitch app that can do that.

There is also twitch points, you would need to make a different script with different libraries to make that possible, but it won't work with bits.

And the last option that you can do with this plugin is to use the bits event, https://github.com/tmijs/docs/blob/gh-pages/_posts/v1.4.2/2019-03-03-Events.md#cheer

the disadvantage of this approach, you would have to make them do something like !redeem reward1 Cheer100

and then you can read the payload to extract the amount of bits used to verify the amount and the message to extract "reward1", I don't think this approach is perfect but it can be done with no extra requirements.

diegozalez commented 1 year ago

Thanks for the answer, sorry I meant with channel points rewards I think I can manage it by adding some text and then reading the message and the the property "custom-reward-id:"

emiliobool commented 1 year ago

oh ok, for that you can use the raw message node,

check that the message id comes from jtv message.tags.username === 'jtv' and check if your id is present in const rewardtype = message.tags['custom-reward-id'];

the first step is not a requirement but will eliminate most normal messages from the second check and only leave announcement type messages

diegozalez commented 1 year ago

Awesome it works, Thanks so much for your help!!!