How to pick specific item from list

Hell y’all, new nigthbot user here, struggeling to create custom commands.

I am looking for a command to calculate the age of 8 different owlets, depended of the owlets name given. Thinking of something like:
!age Jakk => “Jakk is 21 days old.” (Jakk is 1 name, we have 7 more)

His age i can determine with ’ $(COUNTUP birthdate)’ . But how do i make the command select the correct birthdate for each of the 8 owlets?
It needs to check the given name after !age [name], with 8 possible names and select the correct brithdate with that name.

All support is welcome.

PS: I got this to convert the $^&@ time format coming out of COUNTUP, to show ONLY in total days and drop the time details:
$(eval a=$(countup 03 07 2020 12:00:00 PM PST8PDT).replace( year,|year).replace( month,|month).replace( day,|day).split( );b=0;for(i=0;i<a.length;i++){c=parseInt(a[i].split(|)[0]);if(a[i].includes(|year)){b+=c*365;a[i]=;}if(a[i].includes(`|month`)){b+=c*31;a[i]=;}if(a[i].includes(|day)){b+=c;a[i]=``;}}${b} days ; )

So what i need is a lookup of the name to insert the correct known birthdate.

Hey @cyber_smile!

You could create a paste on Pastebin for that, create an account so you can go back to edit your paste later on.

Then your paste would look like this for example:

Name#1, Birthdate#1,
Name#2, Birthdate#2,
Name#3, Birthdate#3,
Name#4, Birthdate#4,
Name#5, Birthdate#5,
Name#6, Birthdate#6,
Name#7, Birthdate#7,
Name#8, Birthdate#8

And then go through the paste like this:

$(eval p=`$(urlfetch https://pastebin.com/raw/XXXXXXXX)`.split(`,`);for(i=0;i<p.length;i++){if(p[i]==`$(query)`){date=p[i+1];}}a=$(countup date).replace( year,|year).replace( month,|month).replace( day,|day).split( );b=0;for(i=0;i<a.length;i++){c=parseInt(a[i].split(|)[0]);if(a[i].includes(|year)){b+=c*365;a[i]=;}if(a[i].includes(`|month`)){b+=c*31;a[i]=;}if(a[i].includes(|day)){b+=c;a[i]=``;}}${b} days;)

XXXXXXXX being the ID of your paste of course.

1 Like

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