Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement /unblacklistall command #2800

Merged
merged 1 commit into from Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions commands.js
Expand Up @@ -2149,6 +2149,26 @@ let commands = exports.commands = {
},
unblacklisthelp: ["/unblacklist [username] - Unblacklists the user from the room you are in. Requires: # & ~"],

unblacklistall: function (target, room, user) {
if (!this.can('editroom', null, room)) return false;

if (!target) {
user.lastCommand = '/unblacklistall';
this.errorReply("THIS WILL UNBLACKLIST ALL BLACKLISTED USERS IN THIS ROOM.");
this.errorReply("To confirm, use: /unblacklistall confirm");
Copy link
Contributor Author

@panpawn panpawn Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good idea... especially if used accidentally.

This kind of prevents the "if used accidentally" scenario, for the most part

return;
}
if (user.lastCommand !== '/unblacklistall' || target !== 'confirm') {
return this.parse('/help unblacklistall');
}

let unblacklisted = Punishments.roomUnblacklistAll(room);
if (!unblacklisted) return this.errorReply("No users are currently blacklisted in this room to unblacklist.");
this.addModCommand(`All blacklists in this room have been lifted by ${user.name}.`);
this.logEntry(`Unblacklisted users: ${unblacklisted.join(', ')}`);
},
unblacklistallhelp: ["/unblacklistall - Unblacklists all blacklisted users in the current room. Requires #, &, ~"],

blacklists: 'showblacklist',
showbl: 'showblacklist',
showblacklist: function (target, room, user) {
Expand Down
17 changes: 17 additions & 0 deletions punishments.js
Expand Up @@ -726,6 +726,23 @@ Punishments.roomUnblacklist = function (room, userid) {
return Punishments.roomUnpunish(room, userid, 'BLACKLIST');
};

Punishments.roomUnblacklistAll = function (room) {
const roombans = Punishments.roomUserids.get(room.id);
if (!roombans) return false;

let unblacklisted = [];

roombans.forEach((punishment, userid) => {
if (punishment[0] === 'BLACKLIST') {
Punishments.roomUnblacklist(room, userid);
unblacklisted.push(userid);
}
});
if (unblacklisted.length === 0) return false;
Punishments.savePunishments();
return unblacklisted;
};

/*********************************************************
* Checking
*********************************************************/
Expand Down