Calculating a required bet amount to recover a specific loss is not too difficult...and if you're randomly selecting the chance, this complicates things slightly, but it should still be doable... For starters, you'd need to know the "house edge", so you can calculate the payout from the given "chance". I believe that the dicebot has an inbuilt "house edge" variable...
site.edgeFor example, when logged into Crypto.games, it shows as:
The formula for calculating payout from chance is:
Payout = (100 - edge) / chance
So, if we randomly generate a chance --> 40
Payout = (100 - 0.8 ) / 40
Payout = 2.48
So far, so good... but that's the easy stuff!
Calculating the required bet to recover our total losses is a bit "complicated":
Profit required = (Bet * Payout) - Bet
Which reduces down to:
Bet Required = Profit Required / (Payout - 1)
If our basebet was 10 PLAY... and we'd lost... our profit would be -10 PLAY... so with a payout of 2.48 we'd need to bet:
Bet Reqd = 10 / (2.48 - 1)
Bet = 10 / 1.48
Bet = 6.76
Or, if after several losses, our profit was at -100 PLAY... and the "random" chance picked for our next bet was 87... the calculations would be:
Payout = (100 - 0.8 ) / 87
=> 1.14
Bet Reqd = 100 / (1.14 - 1)
=> 100 / 0.14
=> 714.29
If you can't work out the actual code required to implement these two formulas, let me know and I'll try and whip up a demo script.