AmberCutie's Forum
An adult community for cam models and members to discuss all the things!

CB App Devs

  • ** WARNING - ACF CONTAINS ADULT CONTENT **
    Only persons aged 18 or over may read or post to the forums, without regard to whether an adult actually owns the registration or parental/guardian permission. AmberCutie's Forum (ACF) is for use by adults only and contains adult content. By continuing to use this site you are confirming that you are at least 18 years of age.
Status
Not open for further replies.

KingMarti

Cam Model
Jul 9, 2017
3,957
1
7,278
163
Romania
kingmarti.com
Twitter Username
@KingMartiCam
MFC Username
King_marti
Streamate Username
Thekingmarti
Chaturbate Username
KingMarti
ManyVids URL
https://www.manyvids.com/Profile/1000252053/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:
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).
 
Little update, I can isolate the media.tokens now and have them write out to chat, just cant get them to update the tip goal. Not getting NaN anymore, now it just stays at 0
 
  • Like
Reactions: Maxi
Upvote 0
after almost 5 hours debugging I got it working... tip total is updating, subject is updating and the custom panel row I added for the last media item purchased is also updating.

Not 100% sure what the issue was tbh, I was using chat gpt to try and fill in some of the blanks in my js knowledge and it seems that chatgpt was what was causing the issues.

Code:
cb.onMediaPurchase((user, media) => {
 
instead of the (function(mediaPurchase) seems to be what got it working. 

also for some unknown reason cb.chatNotice(`${media.tokens'} on the 2nd line of the function cause it to tell me that media.tokens isnt defined but it was perfectly fine further down in the function (and it wasnt any more defined at that point).

Now I need to ice my wrists, moved my cam set up to a less than friendly position for long periods of time typing 😂 Still need to test it a bit more but I am so freaking sick of doing re-capcha's right now since it was media purchases every test needed a new account 😂
 
  • Like
Reactions: Maxi
Upvote 0
Status
Not open for further replies.