No "per User" Cooldown, if !roll is successful

Hey Phantombot-Community,

i’m using the !roll command and set a “per user” cooldown.
Now i want to re-configure the command.
If a user gets “doublets” like “6 and 6” or “4 and 4” the cooldown should be ignored so user could !roll once again.

Is it possible to biuld such a rule.
If theres a chance to control a cooldown behavior directly in the roll.js i would delete the actual cooldown-rule.

Greetings and thanks for your help
Spliddorama

The script would have to be modified to have specialized cooldown behavior. The cooldown logic is meant as a generic driver for any command. For example, the !adventure command has a specialized cooldown handler, although not on a user by user basis.

Every user should have an own cooldown like a non-global cooldown-rule.
But if a user !roll a doublet the personal user cooldown from this !roll should be ignored so that this specific user can !roll again.

All other users should keep their own personal cooldown.

What i want is something like „nice doublets! Roll the dice again“ like on Monopoly for example.

I take a look to the adventure.js

keep in mind that it would also need to be added to the isSpecial() function in PhantomBot\scripts\core\commandCoolDown.js

I’m not able to solve it.
Is ist possible to set the Cooldown for the user/sender in file (roll.js)?
If someone rolls no doublets i add a line which sets the cooldown. Otherwise there is no cooldown and no rule!?

Then, let us make this easier, I set a per-user cooldown for !roll; note that when I rolled doubles that I could run it without a problem, when I didn’t roll doubles, the cooldown hit:

[04-10-2019 @ 22:35:27.635 MDT] illusionaryone: !roll
[04-10-2019 @ 22:35:27.640 MDT] [MUTED] Pleeb IllusionaryOne rolls a [2] and [2]. Hard four for 16 bits! GOOOOOOOAAAAAL!!
[04-10-2019 @ 22:35:30.558 MDT] illusionaryone: !roll
[04-10-2019 @ 22:35:30.563 MDT] [MUTED] Pleeb IllusionaryOne rolls a [6] and [6]. Boxcars to the max!!! 144 bits! The way to success is always difficult, but you still manage to get yourself on top and be honored.
[04-10-2019 @ 22:35:34.245 MDT] illusionaryone: !roll
[04-10-2019 @ 22:35:34.248 MDT] [MUTED] Pleeb IllusionaryOne rolls a [1] and [3]. L-O-S-E-R...
[04-10-2019 @ 22:35:37.446 MDT] illusionaryone: !roll
[04-10-2019 @ 22:35:37.448 MDT] [MUTED] @IllusionaryOne, command !roll is still on cooldown. (1 seconds)

This is the code change in roll.js, you need to add one line of code that is noted below.

            if (dice1 == dice2) {
                loadPrizes();
                switch (dice1) {
                    case 1:
                        resultMessage += $.lang.get('roll.doubleone', $.getPointsString(prizes[dice1 - 1]));
                        break;
                    case 2:
                        resultMessage += $.lang.get('roll.doubletwo', $.getPointsString(prizes[dice1 - 1]));
                        break;
                    case 3:
                        resultMessage += $.lang.get('roll.doublethree', $.getPointsString(prizes[dice1 - 1]));
                        break;
                    case 4:
                        resultMessage += $.lang.get('roll.doublefour', $.getPointsString(prizes[dice1 - 1]));
                        break;
                    case 5:
                        resultMessage += $.lang.get('roll.doublefive', $.getPointsString(prizes[dice1 - 1]));
                        break;
                    case 6:
                        resultMessage += $.lang.get('roll.doublesix', $.getPointsString(prizes[dice1 - 1]));
                        break;
                }

                $.say(resultMessage + $.gameMessages.getWin(sender, 'roll'));
                $.inidb.incr('points', sender, prizes[dice1 - 1]);
                $.coolDown.set('roll', true, 0, $.isMod(sender), sender);  // This is the new code, reset the cooldown to 0 seconds, effectively removing it.
            } else {
                $.say(resultMessage + $.gameMessages.getLose(sender, 'roll'));
            }

The following is optional, just a suggestion to make upgrading PhantomBot easier so you only have to deal with the the custom scripts directory.

You may decide to take a copy of roll.js and place into the scripts/custom folder and make another modification:

    $.bind('initReady', function() {
        $.registerChatCommand('./custom/roll.js', 'roll');
        $.registerChatSubcommand('roll', 'rewards', 1);
    });

You would then decide to just remove scripts/games/roll.js and restart PhantomBot.

You would then decide that when you install a new version of PhantomBot to remove that script again and bring over your scripts/custom directory too so you don’t lose it. Up to you.

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