Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (message.indexOf('!addcom') === 0) {
  2.         if (typeof args[1,2] !== 'undefined' && args[1].trim() !== '') {
  3.             if (user.special.indexOf('mod') >= 0 || user.special.indexOf('broadcaster') >= 0) {
  4.                 message.split(" ");
  5.                 args[2] = args.slice(2).join(" ");
  6.                 connection.query('SELECT 1 FROM commands WHERE channel = "'+channel+'" AND command = "'+args[1]+'"', function(err, rows, fields) {
  7.                     if (err) {
  8.                         client.say(channel, "An error occured:" +err);
  9.                     }
  10.                     else if (!rows.length) {
  11.                         connection.query('INSERT INTO commands (channel, command, response) VALUES ("'+channel+'","'+args[1]+'","'+args[2]+'")');
  12.                         client.say(channel, "The command " +args[1]+ " was succesfully created!");
  13.                     }
  14.                     else {
  15.                         client.say(channel, "The command " +args[1]+ " already exists!");
  16.                     }
  17.                 });
  18.             }
  19.             else {
  20.                 client.say(channel, user.username+", you're not a moderator and therefore you're not allowed to run this command!");
  21.             }
  22.         }
  23.         else {
  24.             client.say(channel, "Syntax error: !addcom [!command] [message]");
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement