- Jul 9, 2017
- 3,957
- 1
- 7,278
- 163
- Twitter Username
- @KingMartiCam
- MFC Username
- King_marti
- Streamate Username
- Thekingmarti
- Chaturbate Username
- KingMarti
Modifing the tipgoal app to include media purchases (well trying to at least)
So far I can get the function to fire on a media purchase but using media.tokens returns NaN (its not in the docs as far as I could find but a comment on the MediaPurchase page say's it should work).
here's a code sample of what I have so far:
I'm not normally programing in JS so this might be a basic question, but is there anyway to print out the keys and values either to the chat I was trying to do this with the cb.chatNotice mediaPurchase but that's just returning Notice: [object Object] in the chat. I have a funny feeling that mediaPurchase.tokens is returning a string not an int which would explain the NaN error, is there anyway to dump the entire media purchase object to check that?
I tried mediaPurchase.amount too, same NaN result and Notice: [object Object] in chat (I tried having them set to console.log but nothing was logging for them).
So far I can get the function to fire on a media purchase but using media.tokens returns NaN (its not in the docs as far as I could find but a comment on the MediaPurchase page say's it should work).
here's a code sample of what I have so far:
Code:
onMediaPurchase(function (mediaPurchase) {
if (mediaPurchase) {
total_tipped -= mediaPurchase.tokens;
if (total_tipped < 0) {
total_tipped = 0;
}
update_subject();
cb.drawPanel()
cb.chatNotice(`${mediaPurchase}`);
cb.changeRoomSubject(`${cb.settings.goal_description} [${cb.settings.tokens - total_tipped} tokens remaining]`);
}
});
I'm not normally programing in JS so this might be a basic question, but is there anyway to print out the keys and values either to the chat I was trying to do this with the cb.chatNotice mediaPurchase but that's just returning Notice: [object Object] in the chat. I have a funny feeling that mediaPurchase.tokens is returning a string not an int which would explain the NaN error, is there anyway to dump the entire media purchase object to check that?
I tried mediaPurchase.amount too, same NaN result and Notice: [object Object] in chat (I tried having them set to console.log but nothing was logging for them).