Pulling a specific pastebin entry

Asked Aug 27, 2025·4 replies·Last activity 11 months ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hello, I have a small amount of experience creating commands but am having some trouble trying to figure out the proper syntax for what I need. I'd like to be able to fetch info about specific Pokémon with a !dex command, I've decided to take on the task of creating a pastebin to draw info from so that it fits the character limit for twitch while also being informative about each Pokémon. I'm using JSON format with the entries as such:
{"Pokémon1":"Info about Pokémon 1",
"Pokémon2":"Info about Pokémon 2",
"Pokémon3":"Info about Pokémon 3"
}

What would be the best way for me to target each specific entry, for example, if I want to know about Pokémon 1, I can do !dex Pokémon1 and retrieve the appropriate information?

4 replies

Something like the following probably works (untested)

Pastebin json:

json
{
"Pokémon1":"Info about Pokémon 1",
"Pokémon2":"Info about Pokémon 2",
"Pokémon3":"Info about Pokémon 3"
}

Nightbot command:

!commands add !dex $(eval const pokedex = $(urlfetch json PASTEBIN_RAW_URL); const item = `$(query)`; pokedex[item])

I created a command of that style and added a message in case they use the empty command without text and another error message in case they misspell a number

$(eval const data = $(urlfetch json https://pastebin.com/raw/******); const query = '$(query)'.toLowerCase(); query === '' ? "Use !dex followed by a number between 001 (always 3 digits) and 1025 to search the entire pokedex." : data[query] || "No Pokémon with that number were found. Remember that between 001 and 099 you need to write 3 digits.
";)

I tested this a bit and it worked great! :) thank you! I can't wait to try it more when I have the pastebin finished ~

Thank you, that's awesome! I love the idea of a helpful error message ~ I tried it briefly and got an error but I may have missed some syntax, thank you for your help!