Skip to content
Turntablelover edited this page May 31, 2013 · 1 revision
var voteCount = [];

bot.on('speak', function (data) {
    var text = data.text.trim();
    // .trim() removes any whitespace around your data.text

    if (text.match(/^\/skip/i)) {
      // ^ means regex must match start of string, not anywhere in the string
      // \/ is the backslash escaped
      // skip is your command
      // i at the end makes it case insensitive
      if (voteCount.indexOf(data.userid) < 0) {
        // if something is not in your array, it will return -1, thus the test for less than 0
        // you need to figure out what "something" should be

        // and here you need to add your user's ID that just typed the command to the array
        voteCount.push(data.userid);


        if (voteCount.length >= 1) {
          bot.speak('I am sorry but your song had to be skipped!');

          if (bot.currentDjId)
            bot.remDj(bot.currentDjId);


          bot.on('newsong', function (data) {
              voteCount.length = 0;
            });

        }
      }
    }

  });

Clone this wiki locally