Closed Chifilly closed 7 years ago
You mean TAPIC.emit ?
Can you paste in some code that doesn't work as intended and explain what exactly you're trying to do with it?
I made TAPIC.emit() to be complete in the API, but I didn't think anyone else would use it to be honest, although I do use it internally for all the events.
Although eventDetail really shouldn't have a string type check.
This is an example I am sending to TAPIC.emit (yes I did mean emit, dunno why I put event)
TAPIC.emit('sub', {
name : 'chifilly',
user_id : 25634037,
user_type : 'streamer',
room_id : 25634037,
months : 24,
resub : true,
plan : 'Prime',
planName : 'Twitch Prime',
sysMsg : 'chifilly\shas\ssubscribed\sfor\s6\smonths!',
joinedText : 'best stream ever!'
});
This returns the error
Invalid parameters. Usage: TAPIC.emit(eventName, eventDetail);
But if I JSON.stringify
the object, it works fine, but it causes the side-effect explained in my first post. And the reason I'm using TAPIC.emit is because it's really useful for testing callbacks.
I know what's wrong but can't fix it for a day or so, sorry. It's just the type checking as I thought.
No worries, thanks for the super fast response though :)
should be fixed
Is the NPM package updated, or do I need to include the git repo manually?
Oh I knew I forgot something. Npm isn't updated but GitHub is.
NPM updated, let me know if it works
Just got around to testing it, and it works perfectly now, thanks very much :)
If I try and use
TAPIC.emit
, I get;except if I use the follow and host events. I tested follow, sub, bits and host. I'm assuming it wants a
JSON.stringify
entry for eventDetails since it fails if I use an object, but it makes things inconsistent because if you fire the event manually, it only works if you send a string, and then the event itself returns a string instead of an object, but if the event is fired normally, it returns an object (at least I assume it returns an object, I don't have a way of testing it, and in the example, it indexes into an object and there's noJSON.parse
).The reason this is an issue for me is when the event fires, I want to store a
JSON.stringify
version in a file, but if youJSON.stringify
a string, it comes out all weird with a lot of escaped characters, and it needs parsing twice