Uptime in dog years

I need help to make a command!

I can’t for the life of me figure out how to multiply the fetched information that “!uptime” gets by 7.

any help or tips would be very appreciated.

P.S. This is my first time trying to make a command and I know it is probably easy I just can’t understand JS.

Well firstly do you want the command to roll over minutes second and hours into the next one so it would show 13 hours 52 minutes 20 seconds or do you want it to be able to show like this 7 hours 350 minutes 140 seconds

These are both 7x 1 hour 50 minutes 20 seconds.

Hey @lillezon!

Okay, I made you a command that would convert 1 hour 50 minutes 20 seconds to 12 hours 52 minutes 20 seconds as I think that’s what you’re looking for.
There could be some errors if the command is called at 0 minute/second/etc as it simply removes the value instead of giving a 0, so that gives ~0.02% of errors. Since it could be “minute” or “minutes” I didn’t have enough room to include the tests required to make it perfect.
One solution would have been to create a Pastebin to fit the more complete code, but I tried to keep it as simple as possible to only use Nightbot, that said I didn’t manage to make it fit under 500 characters, so we’ll be using an alias command as well.

So here are the commands, just copy/paste them in your chat:

!addcom !dogy -a=_dogy $(eval t=`$(twitch $(channel) "{{uptimeLength}}")`.replace(/\s?year(s)?/,``).replace(/\s?month(s)?/,``).replace(/\s?day(s)?/,``).replace(/\s?hour(s)?/,``).replace(/\s?minutes(s)?/,``).replace(/\s?second(s)?/,``).split(` `);t.reverse();m=[1,60,3600,86400,2592000,31536000];for(i=0;i<t.length;i++){t[i]=Number(t[i])*m[i]*7;}s=t.reduce((a,b)=>a+b);m.reverse();c=[];for(i=0;i<m.length;i++){c.unshift(Math.floor(s/m[i]));s=s%m[i];}c.join(`|`);)

!addcom _dogy $(eval q=`$(query)`.split(`|`);`${q[5]} year(s) ${q[4]} month(s) ${q[3]} days(s) ${q[2]} hour(s) ${q[1]} minute(s) ${q[0]} second(s)`)

The command you use to convert the time in dog time is !dogy.

If you don’t plan on streaming more than 24h ever, we can simplify the commands down to one command:

!addcom !dogy $(eval t=`$(twitch $(channel) "{{uptimeLength}}")`.replace(/\s?hour(s)?/,``).replace(/\s?minutes(s)?/,``).replace(/\s?second(s)?/,``).split(` `);t.reverse();m=[1,60,3600,86400];for(i=0;i<t.length;i++){t[i]=Number(t[i])*m[i]*7;}s=t.reduce((a,b)=>a+b);m.reverse();c=[];for(i=0;i<m.length;i++){c.unshift(Math.floor(s/m[i]));s=s%m[i];}`${c[3]} days(s) ${c[2]} hour(s) ${c[1]} minute(s) ${c[0]} second(s)`)

If you think you’ll do more than 24h a few times, but never more than 4 days in a row, you can use this one:

 !addcom !dogy $(eval t=`$(twitch $(channel) "{{uptimeLength}}")`.replace(/\s?day(s)?/,``).replace(/\s?hour(s)?/,``).replace(/\s?minutes(s)?/,``).replace(/\s?second(s)?/,``).split(` `);t.reverse();m=[1,60,3600,86400];for(i=0;i<t.length;i++){t[i]=Number(t[i])*m[i]*7;}s=t.reduce((a,b)=>a+b);m.reverse();c=[];for(i=0;i<m.length;i++){c.unshift(Math.floor(s/m[i]));s=s%m[i];}`${c[3]} days(s) ${c[2]} hour(s) ${c[1]} minute(s) ${c[0]} second(s)`)
1 Like

Thank you!
I really appreciate this. Love you man!

1 Like

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