plugCubed / plugAPI

A generic API for creating plug.dj bots
MIT License
78 stars 45 forks source link

WaitList Ban #134

Closed TheOllih closed 7 years ago

TheOllih commented 7 years ago

WaitList Ban API

BAN WL: Function for ban user from wait list

PlugAPI.prototype.moderateWaitListBan = function(uid, reason, duration, callback) {
    if (!room.getRoomMeta().slug || this.guest) return false;

    if (duration != null) {
        if (!objectContainsValue(PlugAPI.WLBAN, duration)) return false;
    } else {
        duration = PlugAPI.WLBAN.HOUR;
    }

    if (reason != null) {
        if (!objectContainsValue(PlugAPI.WLBAN_REASON, reason)) return false;
    } else {
        reason = PlugAPI.WLBAN_REASON.SPAMMING_TROLLING;
    }

    const user = this.getUser(uid);

    if (user !== null ? room.getPermissions(user).canModBan : this.havePermission(undefined, PlugAPI.ROOM_ROLE.BOUNCER)) {
        if (duration === PlugAPI.WLBAN.PERMA && this.havePermission(undefined, PlugAPI.ROOM_ROLE.BOUNCER) && !this.havePermission(undefined, PlugAPI.ROOM_ROLE.MANAGER)) {
            duration = PlugAPI.WLBAN.SHORT;
        }

        queueREST('POST', 'booth/waitlistban', {
            userID: uid,
            reason,
            duration
        }, callback);

        return true;
    }

    return false;
};

UNBAN WL: Function for unban user from wait list

PlugAPI.prototype.moderateWaitListUnBan = function(uid, callback) {
    if (!room.getRoomMeta().slug || !this.havePermission(undefined, PlugAPI.ROOM_ROLE.MANAGER) || this.guest) {
        return false;
    }

    queueREST('DELETE', 'booth/waitlistban/' + uid, undefined, callback);

    return true;
};

Duration: Wait List Ban Lengths

PlugAPI.WLBAN = PlugAPI.prototype.WLBAN = {
    SHORT: 's',
    HOUR: 'm',
    DAY: 'l',
    PERMA: 'f'
};

Reasons: Wait List Ban Reasons

PlugAPI.WLBAN_REASON = PlugAPI.prototype.WLBAN_REASON = {
    SPAMMING_TROLLING: 1,
    VERBAL_ABUSE: 2,
    OFFENSIVE_MEDIA: 3,
    INAPPROPRIATE_GENRE: 4,
    NEGATIVE_ATTITUDE: 5
};
Dazzuh commented 7 years ago

Looks like you've made the changes on the wrong branch. You're merging all the changes from the es2015 branch into the master branch, these are deliberately different and we're not merging them quite yet.