Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- O comando é !tempo <id do jogo>
- Baixe esse arquivo e renomeia para tempoCommand.js
- Coloque o arquivo em scripts/commands
- Troque o STEAM_ID64 para o seu Steam ID
- */
- (function() {
- var STEAM_ID64 = '76561198080168165';
- function _getJSON(url){
- var HttpRequest = Packages.com.gmt2001.HttpRequest;
- var HashMap = Packages.java.util.HashMap;
- var h = new HashMap();
- var responseData = HttpRequest.getData(HttpRequest.RequestType.GET, encodeURI(url), '', h);
- return responseData.content;
- }
- /*
- * @event command
- */
- $.bind('command', function(event) {
- var sender = event.getSender(),
- command = event.getCommand(),
- args = event.getArgs(),
- target = args[0],
- date;
- if (command.equalsIgnoreCase('tempo')) {
- if (target === undefined)
- {
- $.say($.whisperPrefix(sender) + "Modo de usar: !tempo <id do jogo na Steam>");
- return;
- }
- var jsonGameInfo = JSON.parse(_getJSON("https://store.steampowered.com/api/appdetails/?appids="+target));
- var getUserItem = _getJSON("https://decapi.me/steam/hours/"+ STEAM_ID64 +"/"+target+"/readable");
- var finalMessage;
- if(jsonGameInfo[""+ target +""]["success"] == false)
- {
- $.say("Esse jogo não existe na Steam!");
- return;
- }
- else if(getUserItem.startsWith("The "))
- {
- $.say("Opa! Eu não tenho o " + jsonGameInfo[""+ target +""]["data"]["name"]);
- return;
- }
- else
- {
- $.say("No jogo " + jsonGameInfo[""+ target +""]["data"]["name"] + " eu tenho " + getUserItem.replace('week', 'semana').replace('day', 'dia').replace('hour', 'hora').replace('minute', 'minuto'));
- return;
- }
- }
- });
- /*
- * @event initReady
- */
- $.bind('initReady', function() {
- $.registerChatCommand('./commands/tempoCommand.js', 'tempo', 7);
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment