Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. $.on('command', function(event) {
  2. var sender = event.getSender();
  3. var command = event.getCommand();
  4. var argsString = event.getArguments().trim();
  5. var argsString2 = argsString.substring(argsString.indexOf(" ") + 1, argsString.length());
  6. var num_quotes = parseInt($.inidb.get("quotes", "num_quotes"));
  7. var args = event.getArgs();
  8. var quote;
  9. var num;
  10.  
  11. if(command.equalsIgnoreCase("quote")) {
  12. if (argsString.length() > 0 && $.isModv3(sender, event.getTags())) {
  13. num = parseInt(argsString);
  14. } else {
  15. num = $.rand(num_quotes);
  16. }
  17.  
  18. if (isNaN(num_quotes) || num_quotes == 0) {
  19. $.say("There are no quotes at this time");
  20. return;
  21. }
  22.  
  23. if ($.inidb.get("quotes", "quote_" + num) == null) {
  24. $.say("There are only " + (num_quotes) + " quotes right now! Remember that quotes are numbered from 0 to " + (num_quotes - 1 )+ "!");
  25.  
  26. } else {
  27. if($.isModv3(sender, event.getTags())){
  28. $.say("#" + num + ": " + $.inidb.get("quotes", "quote_" + num));
  29. }
  30. }
  31. }
  32.  
  33. if (command.equalsIgnoreCase("addquote")) {
  34. if (!$.isModv3(sender, event.getTags())) {
  35. $.say($.modmsg);
  36. return;
  37. }
  38.  
  39. if (num_quotes == null || isNaN(num_quotes)) {
  40. num_quotes = 0;
  41. }
  42.  
  43. if (argsString.isEmpty()) {
  44. $.say("Usage: !addquote \"This is a quote!\"");
  45. return;
  46. }
  47.  
  48. $.inidb.incr("quotes", "num_quotes", 1);
  49. $.inidb.set("quotes", "quote_" + num_quotes, argsString);
  50.  
  51. $.say("Quote added! There are now " + (num_quotes + 1) + " quotes!");
  52. }
  53.  
  54. if (command.equalsIgnoreCase("editquote")) {
  55. if (!$.isModv3(sender, event.getTags())) {
  56. $.say($.modmsg);
  57. return;
  58. }
  59.  
  60. num = parseInt(args[0]);
  61.  
  62. if (num > num_quotes) {
  63. $.say("There is no quote under that ID, " + sender + "!");
  64. return;
  65. }
  66.  
  67. if (argsString2.isEmpty()) {
  68. $.say("Usage: !editquote <ID> \"This is a quote!\"");
  69. return;
  70. }
  71.  
  72.  
  73. $.inidb.set("quotes", "quote_" + num, argsString2);
  74.  
  75. $.say("Quote #" + num + " changed to: " + $.inidb.get("quotes", "quote_" + num));
  76. }
  77.  
  78. if (command.equalsIgnoreCase("delquote")) {
  79. if (!$.isModv3(sender, event.getTags())) {
  80. $.say($.modmsg);
  81. return;
  82. }
  83.  
  84. if (num_quotes == null || isNaN(num_quotes) || num_quotes == 0) {
  85. $.say("There are no quotes at this time");
  86. return;
  87. }
  88.  
  89. if (argsString.isEmpty()) {
  90. $.say("Usage: !delquote <id>");
  91. return;
  92. }
  93.  
  94. if (num_quotes > 1) {
  95. for (i = 0; i < num_quotes; i++) {
  96. if (i > parseInt(argsString)) {
  97. $.inidb.set('quotes', 'quote_' + (i - 1), $.inidb.get('quotes', 'quote_' + i))
  98. }
  99. }
  100. }
  101.  
  102. $.inidb.del('quotes', 'quote_' + (num_quotes - 1));
  103.  
  104. $.inidb.decr("quotes", "num_quotes", 1);
  105.  
  106. $.say("Quote removed! There are now " + (num_quotes - 1) + " quotes!");
  107. }
  108. });
  109.  
  110. setTimeout(function(){
  111. if ($.moduleEnabled('./commands/quoteCommand.js')) {
  112. $.registerChatCommand("./commands/quoteCommand.js", "quote");
  113. $.registerChatCommand("./commands/quoteCommand.js", "addquote", "mod");
  114. $.registerChatCommand("./commands/quoteCommand.js", "editquote", "mod");
  115. $.registerChatCommand("./commands/quoteCommand.js", "delquote", "mod");
  116. }
  117. },10*1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement