Pulling a specific phrase from a pastebin

Hey guys, I found a post which has an example of this however I couldn’t find a way to have it return the specific phrase without also returning the word used to select it.
I’m wondering if it’s possible to have the command only return the specific text in the pastebin without the word used to select it?

This is the post I’m referring to Creating a command to pull specific information from a URL

Well this is just a guess as to what you want as you haven’t given your exact use case but this will make it not show the search term:

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

Also please try to post in the correct category and not uncategorized. Since this is a nightbot command the correct category would have been Nightbot.

I want to use it to make a simple story game. So each response would just be a simple, ‘something has happened, x to do this or y to do this’.
Using the example, I wasn’t able to get it to work if I changed anything around to just have a simple phrase.
Ah I didn’t realise! I’ll be sure to post in the right place in the future thanks for letting me know

Well the command you were using isn’t very practical for that application. What you’ll want to do is make a pastebin more like this:

{1:{"Prompt":"Start of story Prompt1: Response1, Response2, ResponseX",
"Response1":Number of next Prompt if chosen,
"Response2":Number of next Prompt if chosen,
"ResponseX":Number of next Prompt if chosen},

2:{"Prompt":"Prompt2: Response1, Response2, ResponseX",
"Response1":Number of next Prompt if chosen,
"Response2":Number of next Prompt if chosen,
"ResponseX":Number of next Prompt if chosen},

X:{"Prompt":"PromptX: Response1, Response2, ResponseX",
"Response1":Number of next Prompt if chosen,
"Response2":Number of next Prompt if chosen,
"ResponseX":Number of next Prompt if chosen}}

If you can get your pastebin in order I’ll be able to make a command that can go through it. Feel free to ask about anything you are unsure of. Also if you don’t like the look of responses at the end you can incorporate them into the prompt like this:

You WAKE UP one foggy morning do you LEAVE the room? Or do you STAY in bed for five more minutes? :zzz:

I’ve set up a pastebin with that format in it. I’ve taken a bit of time to try and understand but I think I’m confused how I’d input the phrases and options for each step of the story. Also would this store where the person is up to in the story without the ability to skip or go back or am I overthinking it too much

Well it will just store the current state as is but can store more it depends on your use case. I’ll need to know exactly how you want that to work in those situations. Can you show me what you have in the pastebin so far so I can see what parts you’re struggling with also to correct any mistakes.

I’m still trying to figure out where responses would go and how to format it in the pastebin.

This is what I’ve messed with but I feel like I’m way off {1:{"You wake up in bed, get up or snooze for 5 minutes":"Start of story Prompt1 - Pastebin.com

I didn’t think it would be possible to code without a crazy amount of effort but ideally it would be saved per each user that uses it, so that if they choose anything besides the 2 options given at that time it’ll return something like ‘those weren’t the options you were given’. As well as being able to see the part they’re up to to know what options they have.
I’m ok with any simple version of this that works however I’m just not sure what’s possible.

I can re explain with examples if need be.

This is what that should look like:

{1:{"Prompt":"You wake up in bed, get up or snooze for 5 minutes",
"GET UP":2,

2:{"Prompt":"Prompt if Get up is chosen",

3:{"Prompt":"Prompt if Snooze is chosen",


I didn’t specify before but you should put the responses in CAPITALS

And yes that was what I was planning on doing saving it per user and not letting them choose other options though I was planning on adding universal Go Back and Reset if they are seen right after the command they will go back one or reset altogether respectively.

Ok it makes sense now! And that’s perfect I didn’t think it’d be possible to do back or resets features.

This is what I have so far https://pastebin.com/raw/gcmcZLKy as long as the numbers all link together is it going to be possible to leave only one option or give the user more than 2 options without clashing with the code?

You can have anywhere from 0-infinite responses realistically 0 would be a dead end and require a reset or go back but it’s pretty customizable. I can also allow you to have the option of making your own reset message and message for if they input a response that’s not allowed you’d just want to include this somewhere in the paste:

"NoMatch":"Message if no match is found",
"Reset":"Message if a user resets",

I cant think of any other messages that would need to be hard written other than those two but if you can let me know.
Also technically I could include a inventory option if you need but I would want to know if you want that now. It would make the way the pastebin needs to be set up different.

That’s perfect! With customisation would it possible to remove the reset and back features then put them back in as I desire?
Also would implementing a feature (assuming I’ve turned off reset and back) where the user would somehow not be able to play the game twice during a stream be possible or would that make it too complicated?

Thats so cool that an inventory can be implemented! With what I’ve been thinking of making I don’t think I’d have any use for an inventory system so might go without that.

Yes I can add the ability to turn that off and on. I won’t make any promises about only allowing users to play once per stream as that can get messy but I’ll see what I can do as for turning off the reset and go back just put this:


Ok no problem if the once per stream isn’t doable but the rest sounds great!

I’ve put together a story and I’m starting to input it into the pastebin, it’ll take a bit of time cause of the amount of options tho. I had a few questions while I do that tho, mainly let’s say the command is called !game, if someone just types in !game how is it going to react?

I’ve made the pastebin with all the options I want to include. I figured if I can turn the option to reset on and off that would effectively only allow one game per stream. I was also wondering if it’s easy to have a ‘!game rules’ to show the basic rules of how to play?


Yeah just include “Rules”:“Your Rules Message”,
Somewhere in it I’ll include a default one to probably. I’ll have the command ready as soon as possible :slight_smile:

Ok perfect, awesome thanks so much!

Sorry for the wait I have what should be a working command from my testing. Ok so first the complicated bit.

To get the tokens needed for this command please go here https://twitch.center/customapi/quote/generate and find the 8 and 16 digit tokens.
They are after “token=” and before “&data” the 8 digit one is your PUBLIC_TOKEN and is free to share, your 16 digit one is you PRIVATE_TOKEN and should not be shared.
(This is just a copy and paste cause I don’t wanna type that all for the millionth time lol)

First command I think you choose !game

$(eval I=decodeURIComponent(`$(querystring)`);U=`$(querystring $(userid))`;D=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)`;S=$(urlfetch json YOUR_RAW_PASTEBIN);T=`PRIVATE_TOKEN`;$(urlfetch json https://pastebin.com/raw/5zYWsFV5))

Alias this to the second command in your case I recommend calling it _game or something similar

Second command

$(eval A=`$(urlfetch https://twitch.center/customapi/$(1))`;I=decodeURIComponent(`$(querystring)`); S=$(urlfetch json YOUR_RAW_PASTEBIN);$(urlfetch json https://pastebin.com/raw/QtWpcSxF))

Side Note: I used an edited version of your pastebin to test this I had to fix a few error you left in Game Test - Pastebin.com you are welcome to use this paste or copy it and put it in your own so you can edit it.

That all being said let me know if you find any errors or anything If this is closed by then my discord is PotatoAteHer#0007 or message me on here.

That’s a wild command thanks so much for going to all that effort! I’ve tested it out and set it up properly I’m pretty sure however it’s returning an error saying Error adding data please try again? Any ideas?

Can you show me what pastebin your using? And also the first command minus your private token of course

Yeah sure it’s $(eval I=decodeURIComponent(`$(querystring)`);U=`$(querystring $(userid))`;D=`$(urlfetch json https://twitch.center/customapi/quote/list?token=e7e75b09&no_id=1)`;S=$(urlfetch json https://pastebin.com/raw/N6JpXxma);T=PRIVATETOKEN;$(urlfetch json https://pastebin.com/raw/5zYWsFV5))
It’s just the same test pastebin you sent at the moment.

I did some fiddling and realised I was missing the back ticks around the private token, it seems to be working now. Just to confirm when I do decide to turn on the reset feature do I just replace the false with a message?