Creating a command to pull specific information from a URL

Hello! First time posting on here and on a forum in general.

I was looking to create a command for Nightbot to pull specific information from a pastebin or something similar. The basic idea was just like a normal command and response, except it would all be included in the same command. Something along the lines of:
!supereffective Rayquaza
Nightbot: Rayquaza- 4x: Ice. 2x: Rock, Dragon, and Fairy.
or
!supereffective Lugia
Nightbot: Lugia (Shield)- 2x: Rock, Ghost, Electric, Ice, and Dark.

This would eliminate the need for 20+ different commands on my Twitch. Ideally it would be able to be shared with others as well.

The original idea I had was to modify the popular !quote command by ehsankia and include a Pastebin to add everything at once or to share it with others.

All the commands I write come up with all kinds of errors ranging from a “404 not found” to “Code generation from strings disallowed for this context.”

Any help would be appreciated. I have the basic knowledge, but implementing it has been frustrating. Thanks in advance!

This command does just that.

$(eval a=JSON.parse(`$(urlfetch json https://pastebin.com/raw/C5RtPdgx)`);b=decodeURIComponent(`$(querystring)`).toUpperCase();if(a[b]){c=b+` - `;for(x in a[b]){c+=x+`: `+a[b][x].join(`, `)+`. `;}c.slice(0,400);}else{`No match!`;})

The Paste inside is a Pokedex template. Search allows any casing but make sure each name in the Pokedex is in all caps.

This is so perfect! Thank you so much! I’ll post the finished command with the full pastebin back on this post so that others can use it. I should have it posted in a day or so.

Here is the finished command! I plan on add the different types and combinations to this in the future, but not today.

`$(eval a=JSON.parse(`$(urlfetch json https://pastebin.com/raw/ydsxFMfe)`);b=decodeURIComponent(`$(querystring)`).toUpperCase();if(a[b]){c=b+` - `;for(x in a[b]){c+=x+`: `+a[b][x].join(`, `)+`. `;}c.slice(0,400);}else{`No match!`;})`

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