NightDev Community Forums

Help With A Command :)

Recently been working on a Pokédex commands. It randomly generates Pokémon stats. I was wondering if there was a way to also have a feature to choose specific Pokémon from the list as well. $(eval a=$(urlfetch json https://pastebin.com/raw/example).split(,);a[Math.floor(Math.random()*(a.length-1))])

As far as I know you can only use .split on strings so try

$(eval var a="$(urlfetch json https://pastebin.com/raw/example)";var b=a.split(",");b[Math.floor(Math.random()*b.length)]

As for the pastebin file write it like this:

Pokemon1,Pokemon2,Pokemon3,etc.

I’m going to try this out tonight. I’ll let you know how I get on. Thank you so much @potatoeaterlove

Can’t seem to get this working still. It pulls up random Pokémon perfectly but to choose a specific Pokémon from the list seems impossible at the moment

Sorry I didn’t see the second part how would you want that to look ?
If someone types !command followed by a pokemon name it should pull up that Pokémon?
But if they just type !command it would pull up a random one?
If that’s what you want try this

$(eval var a="$(urlfetch json https://pastebin.com/raw/example)";var b=a.split(",");var c="$(query)";c=="null"?b[Math.floor(Math.random()*b.length)]:c in b?c:"Pokémon “"+c+"” does not exist.")

Also how are you writing the Pokémon’s names in the list all lowercase, all capital, first letter capital?
Anyways hope this helps.

@https://pastebin.com/6AfagFQq First capital. Here is a link to the paste bin so you can check it out :slightly_smiling_face:

Hi @potatoeaterlove think i might be making an error with the pastebin file ? i type !pokemon 5 for instance and it pulls up just the number “5” but none of the information from the actual script.

Ok try this:

$(eval var a="$(urlfetch json https://pastebin.com/raw/6AfagFQq)";var b=a.split(",");var c="$(1)";var d=parseInt(c);c=="null"?b[Math.floor(Math.random()*b.length)]:b[Math.floor(d-1)])

The Pokédex number of the pokemon you want when inputted should bring up its information.

@potatoeaterlove nightbot just keeps saying this now. ‘Code generation from strings disallowed for this context’
Been trying to figure it out all evening. there must be a way XD

Sorry don’t forget to include the /raw I edited it hoping you wouldn’t get the error but turns out I wasn’t fast enough


Also, pokemon descriptions on pokemon 105 and 115 have an extra coma in them cause the array to be two sequences longer also the last coma after mew isn’t needed

Ok i shall fix these issues up and try again :slight_smile: ill let you know how it goes. If there is anyway i can say thankyou for your help, please let me know

1 Like

@potatoeaterlove It works. honestly i can not thank you enough. please let me know if there is anyway i can say thankyou :slight_smile:

1 Like