Random YouTube Video Command

I want to take a bunch of youtube links and have nightbot pick a random link within these links. Is there any way to do this without having the message be too long for a command? Thanks!

@rcola

You can store the links in a Pastebin file. Take a look at this paste I wrote that contains an array of trivia facts. Take note of the most important aspects of the array:

  1. The paste starts and ends with square brackets.
  2. The trivia facts are separated by commas.
  3. Each fact is bounded by backticks.

Go to https://pastebin.com and create a paste with an array of your YouTube links. Make sure to structure the array as specified above. Once you’ve created a paste that reflects these aspects, you can copy and paste the following command setup:

!addcom -cd=5 COMMAND_NAME $(eval a=$(urlfetch json https://pastebin.com/raw/YOURLINK);a[Math.floor(Math.random()*a.length)])

Replace https://pastebin.com/raw/YOURLINK with your raw paste link. Replace COMMAND_NAME with your desired command name.

hi, thanks for the help! there is one problem, though, and that is when you type the command in, it comes back as “Right-hand side of ‘instanceof’ is not an object”. what can i do about this? i have the picture of the chat and my pastebin url linked below:
https://gyazo.com/b95b35d0c5c0d6034d27f3d20708e2e1
https://pastebin.com/3bNQQYma

Go to your paste https://pastebin.com/3bNQQYma and remove the comma after the last link.

Your !randomvideo command needs a fix. Copy and paste this into chat:

!editcom !randomvideo $(eval a=$(urlfetch json https://pastebin.com/raw/3bNQQYma);a[Math.floor(Math.random()*a.length)])

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