I’m trying to make a command that spits out a random pun from a pastebin file as that’s what the other topics like this suggest so I’ve been reading through them to try and figure out what is wrong with mine. I’ve got the command to this:
!commands add !commands add !pun -cd=5 $(eval var pun = “$(urlfetch https://pastebin.com/raw/6q2c0yLC) “.split(”,”); pun[Math.floor(Math.random() * (pun.length - 1))];). (The full stop on the end isn’t there, im just hoping it will stop it from turning into an emoji.)
But whenever I use it, it says its got a 400 character limit so I’m guessing it’s trying to paste the whole file and I can’t find a way to fix it. I’m assuming others have found a way due to other people having success with it but I can’t find a way to work on mine so any help is appreciated.
Yeah your pastebin file needs to be less than 400 character limit. For ease of use I’d recommend just using Ehsan’s Quote System instead.
You can use a Pastebin file that’s over 400 characters. Just use json in your $(urlfetch) variable like so: $(urlfetch json https://pastebin.com/raw/6q2c0yLC)
There are two ways to set up your !pun command:
1: Edit your paste such that each joke is surrounded by quotes (double quotes
"" or single quotes
'') so in $(eval) you can set
pun = [$(urlfetch json https://pastebin.com/raw/6q2c0yLC)]
Then copy and paste this command into chat:
!commands add -cd=5 !pun $(eval pun=[$(urlfetch json https://pastebin.com/raw/6q2c0yLC)];pun[Math.floor(Math.random()*pun.length)])
2: Put a special character at the end of each joke, then in $(eval) use the special character as a separator in the string split() method to create a pun array. I see you’re trying to use a comma as that separator, but the problem is that you used a comma in the middle of some of your jokes, so some of the items in the pun array are only parts of jokes. Edit your paste so that the special character is something far less common than a comma.
Then copy and paste this command into chat. Replace
newSpecialCharacter with your new special character:
!commands add -cd=5 !pun $(eval pun='$(urlfetch json https://pastebin.com/raw/6q2c0yLC)'.split('newSpecialCharacter');pun[Math.floor(Math.random()*pun.length)])
Thank you so much, I got the second option to work with the file over 400 characters and it now works great!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.