Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
better command restrict logic for coebot
} else if (msg[1].equalsIgnoreCase("restrict")
&& msg.length >= 4) {
String command = msg[2].toLowerCase();
String levelStr = msg[3].toLowerCase();
int level = -1;
String cleanLevelStr = "";
if (channelInfo.getCommand(command) != null) {
if (levelStr.equalsIgnoreCase("owner")
|| levelStr.equalsIgnoreCase("owners")) {
level = 3;
cleanLevelStr = "Owners";
}
if (levelStr.equalsIgnoreCase("mod")
|| levelStr.equalsIgnoreCase("mods")
|| levelStr.equalsIgnoreCase("moderator")
|| levelStr.equalsIgnoreCase("moderators")
|| levelStr.equalsIgnoreCase("op")
|| levelStr.equalsIgnoreCase("ops")) {
level = 2;
cleanLevelStr = "Mods";
}
if (levelStr.equalsIgnoreCase("regular")
|| levelStr.equalsIgnoreCase("regulars")
|| levelStr.equalsIgnoreCase("reg")
|| levelStr.equalsIgnoreCase("regs")) {
level = 1;
cleanLevelStr = "Regulars";
}
if (levelStr.equalsIgnoreCase("everyone")
|| levelStr.equalsIgnoreCase("all")) {
level = 0;
cleanLevelStr = "Everyone";
}
if (level == -1) {
send(channel, "Unknown access level: \"" + levelStr + "\"");
} else if (channelInfo.setCommandsRestriction(command, level)) {
send(channel, prefix + command + " restricted to "
+ cleanLevelStr + ".");
} else {
send(channel, "Error setting restriction.");
}
} else {
send(channel, "Command does not exist.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment