Using multiple pastebin sources in one command


I am trying to create a command named !sus which assigns a specified user a random percentage between 1-100%, inclusive, and then depending on the value of that percent, adds additional text from a variety of pastebin sources. For example…

Chat input: !sus valiantEight
Nightbot response: valiantSeven thinks valiantEight is X% sus! This is a randomly selected piece of text depending on the value of X.

Those pieces of text that the command will pull from are all contained in multiple pastebin sources. Each of the pastebin links are formatted in the following fashion:

Line of text;
Another line of text;
A third line of text…;
Etc., etc., etc.,;

Depending on the percent, the command will pick a line of text from those various pastebin sources in the following fashion:

x less than or equal to 24:
x in between 25 and 49, inclusive:
x in between 50 and 74, inclusive:
x in between 75 and 94, inclusive:
x greater than or equal to 95:

I have a command written and I will paste it below (broken up a little bit for readability). Right now it seems to be working, but I can’t include the FULL command because it exceeds the character limit. I am looking for help condensing the command so that it fits within the character limit (or a way to condense all of those various pastebin sources into one, single pastebin source that can be picked apart by the command itself).

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1);

x<=24?`${x}% sus. $(eval y="$(urlfetch json ".split(";"); y[Math.floor(Math.random()*(y.length - 1))])`:

x>=25&&x<=49?`${x}% sus. $(eval y="$(urlfetch json ".split(";"); y[Math.floor(Math.random()*(y.length - 1))])`:

x>=50&&x<=74?`${x}% sus. $(eval y="$(urlfetch json ".split(";"); y[Math.floor(Math.random()*(y.length - 1))])`:

x>=75&&x<=94?`${x}% sus. $(eval y="$(urlfetch json ".split(";"); y[Math.floor(Math.random()*(y.length - 1))])`:

x>=95?`${x}% sus. $(eval y="$(urlfetch json ".split(";"); y[Math.floor(Math.random()*(y.length - 1))])`:` `)

As mentioned, the command is separated a bit for readability, but when strung together without spaces and breaks, it still exceeds the character limit by quite a bit. If anyone has a way to condense this or change the logic to something that fits the character limit, I would greatly appreciate the help :slight_smile:

Thank you very much in advance!!

1 Like

There’s a few potential solutions the one I recommend is putting

Into one pastebin and replace the $(urlfetches) with the different lists just make sure they stay in "’s

Then your command will look like this

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1);$(urlfetch json CondensedPastebinLink))

Thank you kindly for the reply!

That’s a really clever method! I have it setup as the post suggests, but I am currently getting the following response when calling the command !sus in chat:

Input: !sus TEST
Output: valiantSeven thinks TEST is Unexpected identifier

I have the command setup as such:

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1);$(urlfetch json

You can see the command logic in that pastebin link. All of the subsequent pastebin links that are used by the command are inserted into the “parent” pastebin link, so they’re free to look at if necessary although they’re very simple test replies right now and probably aren’t causing any problems.

Any additional help or suggestions would be greatly appreciated! Thanks again :slight_smile:

1 Like

Ok so what you are gonna wanna do is get rid of all the eval and urlfetch sin the pastebin link and make it look like this

`${x}% sus ${a[Math.floor(Math.random()*a.length)]}`
1 Like

Thank you again for the reply! It seems we are making some good progress, but it’s not yet functioning quite as expected.

Input: !sus Test
Output: valiantSeven thinks Test is

The thing is, each time I call the !sus command it looks like it’s actually picking the correct link based on the value of X despite not having that value displayed in the output. If I were to continue to call the !sus command, for example, it would eventually spit out a different pastebin link than the one I’ve shown above in the output example.

Currently, the command itself is:

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1);$(urlfetch json

And the “parent” pastebin link is found here or down below in the code block:





`${x}% sus ${a[Math.floor(Math.random()*a.length)]}`
1 Like

Ok so you are close but what your gonna wanna do is get rid of all but the main pastebin link by just copy and pasting the data from each of the subsequent pastebin’s into their respective place. If that’s to messy for you there is another way but it still involves putting all the pastebins into ones master pastebin in the end.

Though the response you got is actually expected with the given input :wink:

1 Like

Thank you again for the suggestions!

I think I understand what you’re saying, but I don’t think I know how to go about implementing that work. When you say “get rid of all but the main pastebin link by just copy and pasting the data from each of the subsequent pastebin’s into their respective place,” would that mean the “parent” pastebin source becomes the only source? And then all of the responses are written into the command contained in the “parent” source as possible options based on the value of X?

I have an idea how that might go, but the more I research on the solution I am reading that it’s not possible to have eval or urlfetch inside of pastebin links, and the only way I know how to make that work would be through the use of eval.

For example, if I use the following in a Nightbot command without the use of Pastebin …

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1); x<=24?`${x}% sus. $(eval const first = ['One reply option here', 'Another reply option here...']; first[Math.floor(Math.random() * first.length)];)`: x>=25&&x<=49?`${x}% sus. $(eval const second = ['Reply here', 'Another reply here']; second[Math.floor(Math.random() * second.length)];)`: ...etc.

… it will work and choose a reply accordingly. However, if I put that same exact command into a pastebin so that I can heavily expand on the line $(eval const first = ['One reply option here', 'Another reply option here...']; first[Math.floor(Math.random() * first.length)];) by adding many more replies, it will break and return Unexpected identifier.

Assuming we were to move forward with your first suggestion, the one to copy and paste all the responses into the main pastebin, would you be able to help me with what that might look like? It doesn’t look like I’m able to figure out how to make it work without the use of eval :frowning:

Thank you again for all of your time and help, friend! I appreciate it :slight_smile:


So yeah you can’t have eval and urlfetch in a pastebin and have nightbot execute it. What it would look like is this.


x>=25&&x<=49?a="Level two, response one;Level two, response two".split(";"):




`${x}% sus ${a[Math.floor(Math.random()*a.length)]}`

The “TEXT” would just be you copy and pasting what’s in the pastebins right now I filled in number one as an example. (Also side note if it’s the last item in a paste bin you don’t need to include the “;” at the end [It will return null items sometimes])

I also get how it might seem like this makes no sense but what you have to remember is this is all already inside an eval so there is no reason to call another on in the first place. Hope this helped <3

1 Like

Getting a little closer!

With the command itself looking like this…

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1);$(urlfetch json

…and the pastebin source looking like this:

x<=24?a="Level one, response one;Level one, response two".split(";"):x>=25&&x<=49?a="Level two, response one;Level two, response two".split(";"):x>=50&&x<=74?a="Level three, response one;Level three, response two".split(";"):x>=75&&x<=94?a="Level four, response one;Level four, response two".split(";"):x>=95?a="Level five, response one;Level five, response two".split(";"):`${x}% sus ${a[Math.floor(Math.random()*a.length)]}`

The interaction now looks like the following:

Input: !sus valiantEight
Output: valiantSeven thinks valiantEight is Level four, response one,Level four, response two

Input: !sus valiantTen
Output: valiantSeven thinks valiantTen is Level one, response one,Level one, response two

1 Like

Sorry that’s a mistake on my end make it look like this:


if(x>=25&&x<=49){a="Level two, response one;Level two, response two".split(";")}else 




`${x}% sus ${a[Math.floor(Math.random()*a.length)]}`

Notes: Got rid of the last check for x as it shouldn’t be needed
IMPORTANT: all the “else” have a space after them except the last one you may not be able to tell easily due to the way I formatted it but the is important that the space is included.


Looks to be working perfectly, friend! Thank you kindly for all of your time and help, I appreciate it very much!

In the event this can help someone else, the solution summary can be found below (thanks to potatoeaterlove!):

Nightbot command:

$(user) thinks $(query) is $(eval x=Math.floor(Math.random()*100+1);$(urlfetch json

Text/code contained in the pastebin source fetched in the command:

if(x<=24){a="This is one reply from the first range.;This is a second reply from the first range".split(";")}else 

if(x>=25&&x<=49){a="This is one reply from the second range.;This is a second reply from the second range".split(";")}else 




`${x}% sus! ${a[Math.floor(Math.random()*a.length)]}`

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