Nightbot help selecting from a list

I’m basically trying to make a “Who’s that Pokemon” command for a friend, but because of character limits could only get 30 in.
So was looking to use something like Pastebin to list them all and then nightbot select from there.
I’m completely new to this kind of thing, so will need help put as simply as possible.
$(eval a=$urlfetch json mylink);a[Math.floor(Math.random()*a.length)]) is what I had been trying with, but get unexpected identifier and then the math bit.

Am completely new to this kind of thing, so will need it explained very bascally

It’s just a syntax error. You have more closing brackets than opening brackets ^^

Thanks, had missed that, but tried
$(eval a=$urlfetch json mylink );a[Math.floor(Math.random()*a.length)] and $(eval a=$urlfetch json mylink );a[Math.floor(Math.random()*a.length])

both times got unexpected identifier and then the math bit.

Hey @JamesBCFC!

That’s because you forget parenthesis, here’s what you typed with the fix bellow:

$(eval a=$urlfetch json mylink);a[Math.floor(Math.random()*a.length])

$(eval a=$(urlfetch json LINK);a[Math.floor(Math.random()*a.length)])

That said, I’m not sure this will give you the desired result, as this will pick a random item of your array every time, and not give you specific information on the Pokemon you may be looking for, for that have a look here:

That’s exactly what I needed, thanks.
Was starting with the basic thing first, but might try and work on the other one you showed.

I’m finding it works to an extent, so does the character limit apply to what’s in the pastebin too?

If so what could I do as a workaround?

The only limit that applies here is the total length of the response, the length of the JSON file doesn’t matter, so if you only use the JSON to generate an output, you have up to 400 characters per Pokemon description, which should be enough, haha!

I started getting an error again, so took a bunch out until it worked again.
Slowly adding them back in and saw I missed an uptick, which is probably what caused it.

Yeah, these are the common mistakes, also pay close attention to the Note section in the post I linked.
Glad you figured out the issue by yourself though, not many do, good job!

Just had a thought, but would it be possible to link another command?

So the second command would be catch and it would give a successful or unsuccessful result to the last pokemon this command brings out?

I guess I could copy the thing from the fight or duel command for a template to use, but wouldnt know how (or if) it could be linked to this one

I’m not sure I understand what you want to do here with an alias command… It doesn’t seem useful to me.

its not really meant to be a useful thing but a bit of fun.

So if this command I did gave pikachu, other command would be !catch and would give successful/unsuccessful reply for catching pikachu

Ah, now I see what you want to do.
You want the first command to give you the description of one specific command, and then you want to type !catch to try to catch it, right? So that won’t be possible if you want the response to be “$(user) caught POKEMON_NAME”, as Nightbot won’t remember the state of the previous command, or doesn’t read its previous message either, and this is not what aliases are for, they don’t work this way.

The closest response you can get is “$(user) (didn't) caught it!” or something like that.
So here’s a draft of what the command could be:

$(eval r=Math.floor(Math,random()*2); r==1?`$(user) succesfully managed to catch it, congratulations!`:`Unfortunately, $(user) wasn't so lucky this time...`)

ah thanks, yeah wasn’t sure if it was possible, so made something that I think does the same thing as what you put, though probably in a more sloppy way

$(user) threw a pokeball at $(eval a=$(urlfetch json LINK;a[Math.floor(Math.random()*a.length)]) The wild pokémon $(eval R=[was caught!,escaped!];R[Math.floor(Math.random()*R.length)])

all the pokemon in the pastebin I made had ! after their name, so made this one work around that

1 Like

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