Last active
January 27, 2017 15:25
-
-
Save Xyvyrianeth/e92c07372054ccd16f3225e783d1bf71 to your computer and use it in GitHub Desktop.
This file contains 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 banMe = {}; | |
MPP.client.on('a', msg => { | |
args = msg.a.split(' '); | |
cmd = args[0].toLowerCase(); | |
input = msg.a.substring(cmd.length).trim().toLowerCase(); | |
if (cmd == "/kickban") { | |
if (MPP.client.channel.count < 5) { | |
MPP.chat.send("There are not enough people here for me to do that."); | |
} else { | |
if (MPP.client.isOwner()) { | |
if (!input) { | |
MPP.chat.send("Pick a person to kickban from the room and make sure it's an _id and not a name, " + msg.p.name + "!"); | |
} else if (input.length !== 24) { | |
MPP.chat.send("That is not a valid _id!"); | |
} else { | |
if (input !== MPP.client.getOwnParticipant()._id) { | |
var banning; | |
if (Math.ceil(MPP.client.channel.count / 4) > 2) { | |
votesneeded = Math.ceil(MPP.client.channel.count / 4); | |
} else { | |
votesneeded = 2; | |
} | |
for (var pl in MPP.client.ppl) { | |
if (MPP.client.ppl[pl]._id == input) { | |
banning = MPP.client.ppl[pl]; | |
} | |
} | |
if (!banning) { | |
MPP.chat.send("That _id does not belong to a person in this room!"); | |
} else { | |
if (!banMe[banning._id]) { | |
banMe[banning._id] = [msg.p._id]; | |
MPP.chat.send(msg.p._id + " has voted to kickban " + banning.name + "! 1 of " + votesneeded + " votes acquired."); | |
} else { | |
if (banMe[banning._id].indexOf(msg.p._id) !== -1) { | |
MPP.chat.send(msg.p._id + ", you've already voted to kickban that person!"); | |
} else { | |
banMe[banning._id].push(msg.p._id); | |
if (banMe[banning._id].length < votesneeded) { | |
MPP.chat.send(msg.p._id + " has voted to ban " + banning.name + "! " + banMe[banning._id].length + " of " + Math.ceil(MPP.client.channel.count / 4) + " votes acquired."); | |
} else { | |
MPP.chat.send(msg.p._id + " has given the banning vote of " + banning.name + "! BANNED!!"); | |
MPP.client.sendArray([{m: "kickban", _id: banning._id, ms: 3600000}]); | |
delete banMe[banning._id]; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} else if (cmd == "/id") { | |
if (!input) { | |
sendChat("Your _id, " + msg.p.name.Cap() + ": " + msg.p._id); | |
} else { | |
people = info(input); | |
if (people.length === 0) { | |
sendChat("Does not match any names."); | |
} else { | |
moarpeople = []; | |
for (i = 0; i < people.length; i++) { | |
moarpeople.push(people[i].name + "'s _id: " + people[i]._id); | |
} | |
moarpeople.sort(); | |
if (moarpeople.join(" || ").length > 508) { | |
sendChat("That search is not specific enough. Please narrow it down a bit."); | |
} else { | |
sendChat(moarpeople.join(" || ")); | |
} | |
} | |
} | |
} | |
}); | |
setInterval(function() { | |
if (MPP.client.isOwner()) { | |
if (Math.ceil(MPP.client.channel.count / 4) > 2) { | |
votesneeded = Math.ceil(MPP.client.channel.count / 4); | |
} else { | |
votesneeded = 2; | |
} | |
for (var x in banMe) { | |
if (banMe[x].length < votesneeded) { | |
} else { | |
for (var pl in MPP.client.ppl) { | |
if (MPP.client.ppl[pl]._id == x) { | |
banning = MPP.client.ppl[pl]; | |
} | |
} | |
MPP.chat.send("The lowering amount of people in the room has lowered the required amount of votes needed to kickban " + banning.name + ", so... BUH BYE, " + banning.name.toUpperCase() + "!!"); | |
MPP.client.sendArray([{m: "kickban", _id: x, ms: 3600000}]); | |
delete banMe[x]; | |
} | |
} | |
} | |
}, 1000); | |
String.prototype.contains = function(str) { | |
return this.indexOf(str) !== -1; | |
}; | |
function info(name) { | |
var array = []; | |
for (var pl in MPP.client.ppl) { | |
if (MPP.client.ppl[pl].name.toLowerCase().contains(name.toLowerCase())) { | |
array.push(MPP.client.ppl[pl]); | |
} | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment