Let's first of all take a look at the random bjs and then how to fix it into other bjs when creating our bot.
The first thing you need to do is to install your libs
Important libs you need to install
Resource lib
Random lib
Date and time format
Common lib
The random bjs bellow
let d=Math.random(600,200)
let am=d/20
Putting the random bjs in action using 24 hours bjs
function canRun(){
var last_run_at5 = User.getProperty("last_run_at5");
if(!last_run_at5){ return true }
var minutes = (Date.now() - last_run_at5) /1000/60;
var minutes_in_day = 24*60
var next = (minutes_in_day - minutes)
var wait_hours=Math.floor( next /3600)
next-= wait_hours * 60
var wait_minutes=Math.floor(next)
var seconds= Math.floor((next - wait_minutes)*60)
if(minutes < minutes_in_day){
Bot.sendMessage("_❌ Sorry ,you have received your Bonus today
_⚡️ You can receive your next bonus after_:
"+wait_minutes+" minutes and seconds_ " +seconds);
return
}
return true;
}
if(!canRun()){ return }
User.setProperty("last_run_at5", Date.now(), "integer");
let d=Math.random(600,200)
let am=d/20
//Bot.sendMessage(" *You Received:* "+am.toFixed(8)+" TRX ")
let res = Libs.ResourcesLib.userRes("balance");
res.add (am);
Bot.sendMessage ( "*🎁 Today you received* " + "
" +am.toFixed(6)+ " *TRX* " + "
" + "_⚜️ Come back tomorrow and try again.This Is free Bonus_")
Putting the random bjs in action using referral bonus bjs.
function canRun(){
var last_run_at = User.getProperty("last_run_at");
if(!last_run_at){ return true }
return
return true;
}
if(!canRun()){ return }
User.setProperty("last_run_at", Date.now(), "integer");
var referrer = Libs.ReferralLib.currentUser.attractedByUser()
let d=Math.random(600,200)
let am=d/20
if (referrer) {
var referrerRes = Libs.ResourcesLib.anotherUserRes(
"balance",
referrer.telegramid
)
referrerRes.add(am)
Bot.sendMessageToChatWithId(referrer.telegramid, "*New Reward " +am.toFixed(6)+ " *TRX* ")
} else {
Bot.sendMessage()
}
Thanks
ReplyDelete