An !insult command? ( ͡° ͜ʖ ͡°)

If I had a local text file (like a notepad document) with 50 or more lines and one insult on each line, could I have a command, like “!insult”, that pulls one random line from that text doc and Nightbot posts it in chat?

As a little extra, would I be able to make the command targetable like if a user sends “!insult @dave_nugget” in the chat, could Nightbot then @ that targeted user and then puts in the random insult line?

Trust me, this is a VERY important Nightbot command issue, so much so if anyone wants I could post a link to a copy of my insult text file so you can use them and add your own… ( ͡° ͜ʖ ͡°)

Yes this is possible just separate the insults like this


Please make sure to include the square brackets only at the very start of the list and very end.
As for adding a certain user you would make the command as follows.

!addcom !insult $(eval a="@$(touser)";b=$(urlfetch json;b[Math.floor(Math.random()*b.length)])

Now as for adding the user your insulting into the insult it should look like this.

`This is an example insult towards `+a+`.`

+a+ will be replaced with the person you @

Note: You don’t have to use pastebin it’s just an example of something you could use for the file.

So if I had a local text file for insults would I still use urlfetch and then a https link or can I put in the file explorer path for it? Or would I have to upload it and get a shareable link for Nightbot to use?

Yes, as long as the link returns plain text it should work though make sure you include the “json” parameter in the url fetch to circumvent the character limit.

Any suggestions on where to upload it or what kind of URL it’ll accept?
I’ve tried both uploading the .txt file to a google drive and putting the text into a google doc and neither method work.

No, I am not sure as to what URLs are considered valid or not.
Honestly I would recommend creating a pastebin account and just copy and pasting it over there as I know for certain that works. That would be the simplest fix to this I can see.

I’ve tried using a pastebin and pastebin/raw link but they’re not working.

Ok never mind I see the issue you forgot to put a “,” after each insult and a “`” surrounding each one to.
Here how it should be written:


The formatting of this is important for the command functionality.

Do I put a comma after the very last one before the ending square bracket?

No you do not put a comma after the last one it would create an extra component to the array that would return nothing. After your done reformatting try again and it should work.

Nope. Still just getting “Unexpected identifier” back from Nightbot.

Did you change the pastebin link is my first question as you created a new one since your a guest.
If yes can you please link the pastebin file?

$(eval a="@$(touser)";b=$(urlfetch json;b[Math.floor(Math.random()*b.length)])

and I created a new one to do the formatting correction

Ok, you used ’ instead of ` but I doesnt matter I just created a new pastebin for you.

$(eval a="@$(touser)";b=$(urlfetch json;b[Math.floor(Math.random()*b.length)])

I’ve tested it and this works. Though if you plan on ever changing/adding any insults for future use I highly recommend creating an account on pastebin so you can edit and save your posts. Hope I helped <3

1 Like

I really appreciate the effort, I really do, but it’s still not working for me. Still just getting “Unexpected identifier” back from Nightbot.

WAIT, sorry, just noticed the “1” that appears next to the link part of the code got pasted in, one sec

Ayyyyyyyyyy Now it works! Thanks so much @potatoeaterlove! <3

1 Like

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