xjoon
March 12, 2021, 11:15pm
#1
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

xjoon
March 13, 2021, 5:53pm
#3
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

xjoon
March 15, 2021, 7:21pm
#5
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

xjoon
March 15, 2021, 8:20pm
#7
```
!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`}`)
```

!beads 0 15 20

gets the result of: 18 Minutes 180 Seconds.

Sorry I forgot to include 3 pairs of parentheses I edited the command above it should work now

2 Likes

xjoon
March 15, 2021, 10:09pm
#9
Working like a charm. Appreciate your time on this!

system
Closed
March 29, 2021, 10:10pm
#10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.