Added !kick command. Updated perm check logic on chan ban to match.

This commit is contained in:
rainbow napkin 2024-12-29 03:45:06 -05:00
parent ac8d789edb
commit 2ea3c72a61
4 changed files with 157 additions and 7 deletions

View file

@ -120,7 +120,7 @@ channelSchema.pre('save', async function (next){
if(chanDB != null){
//If we're removing one
if(chanDB.rankList.length > this.rankList.length){
//Child/Parent is *WAY* to atomic family for my tastes :P
//Child/Parent is *WAY* tooo atomic family for my tastes :P
var top = chanDB;
var bottom = this;
}else{
@ -133,18 +133,26 @@ channelSchema.pre('save', async function (next){
await top.populate('rankList.user');
//For each rank in the dommy-top copy of the rank list
top.rankList.forEach((topObj) => {
//Create empty variable for the matched rank
var matchedRank = null;
//For each rank in the old copy of the rank list
//For each rank in the subby-bottom copy of the rank list
bottom.rankList.forEach((bottomObj) => {
//So long as both users exist (we're not working with deleted users)
if(topObj.user != null && bottomObj.user != null){
//If it's the same user
if(topObj.user._id.toString() == bottomObj.user._id.toString()){
//matched rank found
matchedRank = bottomObj;
}
}
});
//If matched rank is null or isn't the topObject rank
if(matchedRank == null || matchedRank.rank != topObj.rank){
//Set top object to found rank
foundRank = topObj;
}