Skip to content

Instantly share code, notes, and snippets.

@jeden
Created March 5, 2014 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeden/9370122 to your computer and use it in GitHub Desktop.
Save jeden/9370122 to your computer and use it in GitHub Desktop.
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