Nightbot random command pulls texts that have been deleted.

So ive been using the following command to pull a random line from Pastebin:
$(eval a=$(urlfetch json https://pastebin.com/raw/KPikmQV4).split(;);a[Math.floor(Math.random()*a.length)])

The above line is an example tied with the command !acemanpick (who is a member for my channel).
It has worked fine for the past year, but in my latest stream it started bugging out. The pastebin file contains 10 lines that represents 10 different characters. It represents my members “team” and theyre going to head to head with someone else. When a character is called into the chat and loses, I then cut the line of the character and move it to another pastebin file temporarily until they either lose all their characters or they defeat all of their opponent’s character. The problem is when I remove the lines of characters, after the “pick” command is used again, Nightbot will return the deleted characters sometimes. I spent over 6 hours streaming today, trying different things, changing the code, refreshing pastebin and nightbot after every change, waiting a minute before using the command again. But it would still return deleted lines. Idk if anyone can help me or understands, but ive been struggling trying to figure out why Nightbot seems to be returning lines that arent part of the file anymore.. Any help is highly appreciated.

Something similar happened to me when using Pastebin in PHP for an OBS Widget. I think after several requests to Pastebin, it caches the response.
My solution in PHP was to add a timestamp parameter to the Pastebin URL (https://pastebin.com/raw/XXXXXX?timestamp=".microtime(true)) so it would never be cached.
You’d have to see if that’s possible with urlfetch, or if you’d need to set up an external API.

1 Like

I appreciate that, Ill try that out, thank u