Advertisement
xgerhard

XgBfTracker.js

Mar 3rd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     /**
  3.      * @event command
  4.      */
  5.     $.bind('command', function(event) {
  6.         var defaultConsole = 'xbox'; // Change this to xbox or ps
  7.         var command = event.getCommand();
  8.         var args = event.getArgs();
  9.  
  10.         if (command.equalsIgnoreCase('bf')) {
  11.  
  12.             try {
  13.                 var HttpRequest = Packages.com.gmt2001.HttpRequest;
  14.                 var HashMap = Packages.java.util.HashMap;
  15.                 var h = new HashMap(1);
  16.                 var r = HttpRequest.getData(HttpRequest.RequestType.GET, 'https://2g.be/twitch/BF/command/query=' + args.join(" ") + '&user=' + event.getSender() + '&channel=' + $.channelName + '&defaultconsole=' + defaultConsole + '&bot=phantombot', '', h);
  17.                 if (r.success) {
  18.                     $.say(r.content);
  19.                 } else {
  20.                     if (r.httpCode == 0) {
  21.                         $.say('Failed to connect to the server, please contact Xgerhard on twitch or tweet at @gerhardoh, error code 0');
  22.                     } else {
  23.                         $.say('Failed to connect to the server, please contact Xgerhard on twitch or tweet at @gerhardoh, error code 1');
  24.                     }
  25.                 }
  26.             } catch (e) {
  27.                 $.say('Failed to connect to the server, please contact Xgerhard on twitch or tweet at @gerhardoh, error code 2');
  28.             }
  29.         }
  30.     });
  31.  
  32.     /**
  33.      * @event initReady
  34.      */
  35.     $.bind('initReady', function() {
  36.         if ($.bot.isModuleEnabled('./commands/XgBfTracker.js')) {
  37.             $.registerChatCommand('./commands/XgBfTracker.js', 'bf');
  38.         }  
  39.     });
  40. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement