I was looking for simple quote system pulled out from pastebin.com, for an example using this link(https://pastebin.com/raw/yyUZkteW). Doing !quote #2, pulling out the “I’m now on the mode I’m at” ~ Stan [16.3.2017], [Csgo] to the chat and also if someone types !quote alone can it generate random quotes out of the list!
Looking at this paste, you would have to write up a script with a complex regular expression (search pattern) that tells the bot where each quote starts and ends.
You can avoid that by writing the paste such that the quotes are stored in an array. Look at this example paste used for a trivia command: https://pastebin.com/56L5nKLE
Notice the important aspects of the array:
- The paste starts and ends with square brackets.
- The quotes are separated by commas.
- Each quote is bounded by backticks.
Once you’ve created a paste that reflects these aspects, you can copy and paste the following command setup:
!addcom -cd=5 !quote $(eval a=$(urlfetch json https://pastebin.com/raw/YOURLINK);a[parseInt(decodeURIComponent(`$(querystring)`))-1]||a[Math.floor(Math.random()*a.length)])
https://pastebin.com/raw/YOURLINK with your raw paste link.
This command will output the quote at the specified index if the user provides a number, and will output a random quote if there is no input or the input is a number that doesn’t make sense (ie. the number is greater than the array length or is less than 1).
Thank you @RokettoJanpu for the pointers
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.