Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- /**
- * Add !destiny command through chat:
- * !addcom !destiny (customapi https://2g.be/twitch/destinyv2.php?query=(echo)&user=(sender)&channel=(channelname)&defaultconsole=xbox&bot=phantombot)
- *
- * Add !destiny command as script:
- */
- $.bind('command', function(event) {
- var defaultConsole = 'xbox'; // Change this to xbox or ps
- var command = event.getCommand();
- var args = event.getArgs();
- if (command.equalsIgnoreCase('destiny')) {
- try {
- var errorCode = 0;
- var HttpRequest = Packages.com.gmt2001.HttpRequest;
- var HashMap = Packages.java.util.HashMap;
- var h = new HashMap(1);
- var r = HttpRequest.getData(HttpRequest.RequestType.GET, 'https://2g.be/twitch/destinyv2.php?query=' + args.join("%20") + '&user=' + event.getSender() + '&channel=' + $.channelName + '&defaultconsole=' + defaultConsole + '&bot=phantombot', '', h);
- if (r.success) {
- $.say(r.content);
- } else {
- if (r.httpCode == 0) {
- errorCode = 'http 0';
- } else {
- errorCode = 'http ' + r.httpCode;
- }
- }
- } catch (e) {
- errorCode = 2;
- }
- if (errorCode != 0) $.say('Failed to connect to the server, please contact Xgerhard on twitch or tweet at @gerhardoh, error code: ' + errorCode);
- }
- });
- /**
- * @event initReady
- */
- $.bind('initReady', function() {
- if ($.bot.isModuleEnabled('./commands/XgDestinyCommand.js')) {
- $.registerChatCommand('./commands/XgDestinyCommand.js', 'destiny');
- }
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement