Gain Points by creating Clips (clipsHandler.js)

I want my users to gain points by creating clips on twitch.
So i modified the clipsHandler.js in this way:

under
$.say(s);
in line 38 i add the line;
$.setIniDbString(‘points’, creator, ‘500’);

I’ve also tried:
$.inidb.incr(‘points’, creator, ‘500’);

But there were no points givenb to the user/creator of the clip.
Can you explain, how to give points correctly?

Greetz
Spliddorama

maybe cause creater is not lowercased

Thanks dungi,

but further ahead in the file there’s the following line:

    if (s.match(/\(name\)/g)) {
        s = $.replace(s, '(name)', creator);
    }

“creator” is written in lowercase.
But i will try :wink:

$.inidb.incr() expects an integer value, it is being passed a String. Remove the quotes. When I attempt to pass a String like that:

$.inidb.incr('points', user, '500');

The following error occurs ( I just tossed it into quoteSystem to show the error):

command] Script [./systems/quoteSystem.js] Stacktrace [quoteSystem.js:292 > init.js:315 > init.js:520] Exception [InternalError: The choice of Java method com.gmt2001.datastore.DataStore.incr matching JavaScript argument types (string,string,string) is ambiguous; candidate methods are:
    void incr(java.lang.String,java.lang.String,int)
    void incr(java.lang.String,java.lang.String,long) (quoteSystem.js#292)]

I am surprised you didn’t receive an error. Try changing to:

$.inidb.incr('points', creator, 500);

Thanks for your reply @IllusionaryOne !

But the user gains no points :frowning:

The Code:
/*

  • @event twitchClip
    */
    $.bind(‘twitchClip’, function(event) {
    var creator = event.getCreator(),
    url = event.getClipURL(),
    s = message;

    /* Even though the Core won’t even query the API if this is false, we still check here. */
    if (toggle === false) {
    return;
    }

    if (s.match(/(name)/g)) {
    s = $.replace(s, ‘(name)’, creator);
    }

    if (s.match(/(url)/g)) {
    s = $.replace(s, ‘(url)’, url);
    }

    $.say(s);
    $.inidb.incr(‘points’, creator, 500);
    });

But the value of points didn’t change.

Console:

spliddorama: !coins
[CHAT] /me @Spliddorama, Du hast während deiner Anwesenheit von 236 Stunden und 37 Minuten bisher **110095** splitcoins gesammelt.
[CHAT] /me Spliddorama hat einen Clip erstellt: https://clips.twitch.tv/ImpartialOddPigeonFailFish
[DISCORD] [#clips] [CHAT] Spliddorama hat einen Clip erstellt. https://clips.twitch.tv/ImpartialOddPigeonFailFish
spliddorama: !coins
[CHAT] /me @Spliddorama, Du hast während deiner Anwesenheit von 236 Stunden und 37 Minuten bisher **110095** splitcoins gesammelt.

I can’t find the fault.

points
[04-10-2019 @ 22:16:46.029 MDT] [MUTED] @IllusionaryBot,  you currently have 1250309 bits and you have been in the chat for  102 hours and 50 minutes.
cliptest illusionarybot
[04-10-2019 @ 22:16:48.722 MDT] [CONSOLE] Executing cliptest illusionarybot
[04-10-2019 @ 22:16:48.724 MDT] [MUTED] illusionarybot created a clip: https://clips.twitch.tv/ThisIsNotARealClipAtAll
[04-10-2019 @ 22:16:48.740 MDT] [DISCORD] [#bottest] [EMBED]
points
[04-10-2019 @ 22:16:53.877 MDT] [MUTED] @IllusionaryBot,  you currently have 1260309 bits and you have been in the chat for  102 hours and 50 minutes.

Not sure:

    /*
     * @event twitchClip
     */
    $.bind('twitchClip', function(event) {
        var creator = event.getCreator(),
            url = event.getClipURL(),
            s = message;

        /* Even though the Core won't even query the API if this is false, we still check here. */
        if (toggle === false) {
            return;
        }

        if (s.match(/\(name\)/g)) {
            s = $.replace(s, '(name)', creator);
        }

        if (s.match(/\(url\)/g)) {
            s = $.replace(s, '(url)', url);
        }

        $.inidb.incr('points', creator, 10000);
        $.say(s);
    });

There are times when PhantomBot enters non-commit mode and has to perform some operations before executing all commits to the database. Try waiting a few seconds and then checking points to see if that is the case.

1 Like

Thank you very much for your effort!

If i use “cliptest spliddorama” i get the points indeed.
But if i create a clip on twitch the bot shouts out the clip but did’n distributes points :frowning:

I really had to convert “creator” to lowercase like:
$.inidb.incr(‘points’, creator.toLowerCase(), 500);

Thanks a lot for your help!

So my fix plus what Dungi suggested. Good deal.

Cheers!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.