# Making Nightbot do Math w/ Time?

I was wondering if theres any way to make Nightbot do addition within the format of 60 sec = 1 minute?

For example typing !example 1530 or 15:30 could make it so that !example triggers nightbot to add 160 seconds to 15:30 to get to 1810 or 18:10. Thanks in advance for your time!

Yeah it’s possible any specific parameters?
Like should it always add 180 seconds or should that be changeable?

1 Like

Being changeable would be excellent.

Here you go

!name_of_command

``````\$(eval dy=0;h=\$(1);m=\$(2);s=\$(3);d=\$(4);sn=(d+s)%60;ma=Math.floor((d+s)/60);mn=(m+ma)%60;ha=Math.floor((m+ma)/60);hn=(h+ha)%24;dyn=Math.floor((h+ha)/24);`\${dyn==0?``:`\${dyn} days`} \${hn==0?``:`\${hn} hours`} \${mn==0?``:`\${mn} minutes`} \${sn==0?``:`\${sn} seconds`}`)
``````

Format is !name_of_command {Hours} {Minutes} {Seconds} {Delay_in_Seconds}
Alternatively you can input your own delay in seconds at d=____ instead of allowing them to input there own. Hope this is up to your standards 1 Like

Thank you for your help on this! The way I was hoping to implement this would be:

!example 1520 or 15:20 & nightbot would reply with 18:00 or 1800 (+160)
!example2 1520 or 15:20 & nightbot would reply with 17:30 or 1730 (+130)

would that mean replacing the (4) `d=\$(4)` with the desired amount 130, 160 etc.?

Yes replace \$(4) with desired amount of time in seconds

1 Like
``````!commands add !beads \$(eval dy=0;h=\$(1);m=\$(2);s=\$(3);d=160;sn=d+s%60;ma=Math.floor((d+s)/60);mn=m+ma%60;ha=Math.floor((m+ma)/60);hn=h+ha%24;dyn=Math.floor((h+ha)/24);`\${dyn==0?``:`\${dyn} days`} \${hn==0?``:`\${hn} hours`} \${mn==0?``:`\${mn} minutes`} \${sn==0?``:`\${sn} seconds`}`)
``````