Created
March 5, 2014 16:03
-
-
Save jeden/9370122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
function isPlayerBanned(name,isbanned) { | |
fs.readFile('bans.json', 'utf8', function (err,data) { | |
if (err) { | |
console.log(err); | |
} | |
var retorna; | |
var banFile = {}; | |
var isBanned = true; | |
if ( banFile[name] !== undefined ) { | |
isBanned = true; | |
} | |
if (isBanned){ | |
var banExpiration = banFile[name]; | |
var actualTime = new Date(); | |
var banDate = new Date(banExpiration); | |
var timeban = banDate.getTime(); | |
var time = actualTime.getTime(); | |
if (time > timeban){ | |
console.log("oi"); | |
retorna = false; | |
} else { | |
console.log("falhou denovo :("); | |
retorna = true; | |
} | |
} else { | |
console.log('fail 2'); | |
retorna = false; | |
} | |
return isbanned(retorna); | |
}); | |
} | |
isPlayerBanned('name', function(banned) { | |
console.log(banned); | |
if (banned){ | |
console.log(": You can't add because you are banned. Use !isbanned [yourauthname] to know when the ban will expire."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment