bug fixes, Reaction Toggle Role, Booster Exclusive roles
This commit is contained in:
parent
f05582baaf
commit
fa5c9371f1
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.fpghoti</groupId>
|
||||
<artifactId>Biscuit</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.4</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.fpghoti</groupId>
|
||||
<artifactId>Biscuit</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.4</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
|
|
|
@ -32,6 +32,8 @@ import com.fpghoti.biscuit.listener.JoinListener;
|
|||
import com.fpghoti.biscuit.listener.MessageDeleteListener;
|
||||
import com.fpghoti.biscuit.listener.MessageEditListener;
|
||||
import com.fpghoti.biscuit.listener.MessageReceiveListener;
|
||||
import com.fpghoti.biscuit.listener.ReactionListener;
|
||||
import com.fpghoti.biscuit.listener.RoleListener;
|
||||
import com.fpghoti.biscuit.timer.task.BotMsgRemoveTimer;
|
||||
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
||||
import com.fpghoti.biscuit.timer.task.DecrementTimer;
|
||||
|
@ -72,6 +74,8 @@ public class Main {
|
|||
jda.addEventListener(new MessageDeleteListener());
|
||||
jda.addEventListener(new JoinListener());
|
||||
jda.addEventListener(new DMListener());
|
||||
jda.addEventListener(new ReactionListener());
|
||||
jda.addEventListener(new RoleListener());
|
||||
|
||||
String link = "NULL";
|
||||
|
||||
|
@ -119,6 +123,7 @@ public class Main {
|
|||
ready = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void startJDA() {
|
||||
String token = PropertiesRetrieval.getToken();
|
||||
log.info("Connecting bot to Discord.");
|
||||
|
|
|
@ -29,7 +29,7 @@ public class NotSpammerCommand extends ClientCommand{
|
|||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
SpamRecords.spammers.remove(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer flagged as spam.").queue();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class SoftMuteCommand extends ClientCommand{
|
|||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
SpamRecords.softmute.add(u);
|
||||
u.openPrivateChannel().queue();
|
||||
event.getTextChannel().sendMessage(s+ " is now soft-muted. They will now be only able to send one message every two minutes.").queue();
|
||||
|
|
|
@ -12,35 +12,35 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|||
|
||||
public class ToggleRoleCommand extends ClientCommand{
|
||||
|
||||
public ToggleRoleCommand() {
|
||||
name = "ToggleRole";
|
||||
description = "Toggles specified role on/off";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "togglerole <role>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("togglerole");
|
||||
identifiers.add("tr");
|
||||
}
|
||||
|
||||
public ToggleRoleCommand() {
|
||||
name = "ToggleRole";
|
||||
description = "Toggles specified role on/off";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "togglerole <role>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("togglerole");
|
||||
identifiers.add("tr");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -togglerole " + args[0]);
|
||||
|
||||
|
||||
String rolename = "";
|
||||
|
||||
|
||||
for(String s : PropertiesRetrieval.getToggleRoles()) {
|
||||
if(s.equalsIgnoreCase(args[0])) {
|
||||
rolename = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(rolename.equals("")) {
|
||||
event.getTextChannel().sendMessage("Sorry! This role either cannot be toggled or does not exist!").queue();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Role role = null;
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
if(r.getName().toLowerCase().equalsIgnoreCase(rolename)) {
|
||||
|
@ -51,7 +51,7 @@ public class ToggleRoleCommand extends ClientCommand{
|
|||
b.error("Cannot find role!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
if(e.getName().contains(PropertiesRetrieval.getDoneEmote())) {
|
||||
|
@ -65,7 +65,17 @@ public class ToggleRoleCommand extends ClientCommand{
|
|||
if(PermUtil.hasRole(event.getMember(), role)){
|
||||
event.getGuild().removeRoleFromMember(event.getMember(),role).queue();
|
||||
}else {
|
||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||
boolean canAdd = false;
|
||||
if(PermUtil.isBoosterExclusive(role)) {
|
||||
if(PermUtil.isBooster(event.getMember())) {
|
||||
canAdd = true;
|
||||
}
|
||||
}else {
|
||||
canAdd = true;
|
||||
}
|
||||
if(canAdd) {
|
||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||
}
|
||||
}
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}
|
||||
|
|
|
@ -12,14 +12,14 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|||
|
||||
public class UIDCommand extends ClientCommand{
|
||||
|
||||
public UIDCommand() {
|
||||
name = "User ID";
|
||||
description = "Retrieves a user's ID.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "uid @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("uid");
|
||||
}
|
||||
public UIDCommand() {
|
||||
name = "User ID";
|
||||
description = "Retrieves a user's ID.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "uid @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("uid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
|
@ -27,9 +27,9 @@ public class UIDCommand extends ClientCommand{
|
|||
b.log(event.getAuthor().getName() + " issued a command: -uid " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))
|
||||
event.getTextChannel().sendMessage("DEBUG: " + s+ " retrieved.").queue();
|
||||
if(PermUtil.isMod(event.getMember())) {
|
||||
event.getTextChannel().sendMessage(u.getId()).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class UnSoftMuteCommand extends ClientCommand{
|
|||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
SpamRecords.softmute.remove(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer soft-muted.").queue();
|
||||
}
|
||||
|
|
|
@ -2,15 +2,10 @@ package com.fpghoti.biscuit.config;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
@ -95,7 +90,12 @@ public class ConfigRetrieval {
|
|||
added = addProperty("Custom-Command-Names", "", prop, added);
|
||||
added = addProperty("DisabledCommands", "cmd1,cmd2,cmd3", prop, added);
|
||||
added = addProperty("DisabledUserCommands", "cmd4,cmd5,cmd6", prop, added);
|
||||
|
||||
added = addProperty("ModRole", "biscuit-key", prop, added);
|
||||
added = addProperty("AdminRole", "biscuit-admin", prop, added);
|
||||
added = addProperty("Toggle-Role-React-Channels", "toggleroles1,toggleroles2,toggleroles3", prop, added);
|
||||
added = addProperty("Boost-Exclusive-Roles", "role2,role3", prop, added);
|
||||
added = addProperty("Treat-Like-Booster", "Nitro Booster,silver,gold", prop, added);
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,14 @@ public class PropertiesRetrieval {
|
|||
return ConfigRetrieval.getFromConfig("DefaultRoleName");
|
||||
}
|
||||
|
||||
public static String getModRole(){
|
||||
return ConfigRetrieval.getFromConfig("ModRole");
|
||||
}
|
||||
|
||||
public static String getAdminRole(){
|
||||
return ConfigRetrieval.getFromConfig("AdminRole");
|
||||
}
|
||||
|
||||
public static boolean noCaptchaKick(){
|
||||
String value = ConfigRetrieval.getFromConfig("No-Captcha-Kick");
|
||||
return value.equalsIgnoreCase("true");
|
||||
|
@ -57,7 +65,12 @@ public class PropertiesRetrieval {
|
|||
}
|
||||
|
||||
public static String[] getNaughtyWords(){
|
||||
return ConfigRetrieval.getFromConfig("NaughtyList").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("NaughtyList").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean restrictCmdChannels(){
|
||||
|
@ -66,30 +79,92 @@ public class PropertiesRetrieval {
|
|||
}
|
||||
|
||||
public static String[] getCmdChannels(){
|
||||
return ConfigRetrieval.getFromConfig("CmdChannels").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("CmdChannels").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] getToggleRoles(){
|
||||
return ConfigRetrieval.getFromConfig("ToggleRoles").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("ToggleRoles").replace(" , ", ",").replace(", ", ",").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] getBoostExclusiveRoles(){
|
||||
String [] list = ConfigRetrieval.getFromConfig("Boost-Exclusive-Roles").replace(" , ", ",").replace(", ", ",").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] getBoosterRoles(){
|
||||
String [] list = ConfigRetrieval.getFromConfig("Treat-Like-Booster").replace(" , ", ",").replace(", ", ",").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] blockedUnicodeEmotes(){
|
||||
return ConfigRetrieval.getFromConfig("Block-Unicode-Emotes").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("Block-Unicode-Emotes").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] blockedCustomEmotes(){
|
||||
return ConfigRetrieval.getFromConfig("Block-Custom-Emotes").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("Block-Custom-Emotes").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] getCustomCmds(){
|
||||
return ConfigRetrieval.getFromConfig("Custom-Command-Names").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("Custom-Command-Names").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] disabledCommands(){
|
||||
return ConfigRetrieval.getFromConfig("DisabledCommands").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("DisabledCommands").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] disabledUserCommands(){
|
||||
return ConfigRetrieval.getFromConfig("DisabledUserCommands").replace(" ", "").split(",");
|
||||
String [] list = ConfigRetrieval.getFromConfig("DisabledUserCommands").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] getToggleChannels(){
|
||||
String [] list = ConfigRetrieval.getFromConfig("Toggle-Role-React-Channels").replace(" ", "").split(",");
|
||||
if(list.length == 1 && list[0].equals("")) {
|
||||
String[] blank = {};
|
||||
return blank;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
|||
import com.fpghoti.biscuit.global.MessageQueue;
|
||||
import com.fpghoti.biscuit.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.ChatFilter;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
|
@ -25,6 +26,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
|||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent event){
|
||||
if (event.isFromType(ChannelType.TEXT)) {
|
||||
PermUtil.clearUndeservedRoles(event.getMember());
|
||||
if(Util.isLoggable(event.getTextChannel())) {
|
||||
if(PropertiesRetrieval.logChat()) {
|
||||
log.info( "NEW MSG - MSGID: " + event.getMessageId() + "- @" + event.getAuthor().getName() + " " + event.getAuthor().getAsMention() + " - CHANNEL: #" + event.getChannel().getName() + " - " + event.getMessage().getContentDisplay());
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.message.react.GenericMessageReactionEvent;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class ReactionListener extends ListenerAdapter{
|
||||
|
||||
Logger log = Main.log;
|
||||
|
||||
@Override
|
||||
public void onMessageReactionAdd(MessageReactionAddEvent event){
|
||||
if(event.getGuild() == null) {
|
||||
return;
|
||||
}
|
||||
if(Util.contains(PropertiesRetrieval.getToggleChannels(),event.getTextChannel().getName())) {
|
||||
handleMessageRole(event, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReactionRemove(MessageReactionRemoveEvent event){
|
||||
if(event.getGuild() == null) {
|
||||
return;
|
||||
}
|
||||
if(Util.contains(PropertiesRetrieval.getToggleChannels(),event.getTextChannel().getName())) {
|
||||
handleMessageRole(event, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMessageRole(GenericMessageReactionEvent event, boolean remove) {
|
||||
event.getTextChannel().retrieveMessageById(event.getMessageId()).queue((message) -> {
|
||||
String msg = message.getContentDisplay();
|
||||
for(String rolename : PropertiesRetrieval.getToggleRoles()) {
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
if(r.getName().toLowerCase().equalsIgnoreCase(rolename)) {
|
||||
if(msg.toLowerCase().contains("[toggle " + rolename.toLowerCase() + "]")) {
|
||||
toggleRole(r, event, remove);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, (failure) -> {
|
||||
failure.printStackTrace();
|
||||
});
|
||||
}
|
||||
|
||||
private void toggleRole(Role role, GenericMessageReactionEvent event, boolean remove) {
|
||||
Guild guild = event.getGuild();
|
||||
if(role == null) {
|
||||
return;
|
||||
}
|
||||
Member m = event.getMember();
|
||||
if(remove) {
|
||||
if(PermUtil.hasRole(m, role)) {
|
||||
log.info("REACTION TOGGLE (#" + event.getTextChannel().getName() + ") - Removing role " + role.getName() + " from " + m.getUser().getName() + "(" + m.getId() + ")");
|
||||
guild.removeRoleFromMember(m, role).queue();
|
||||
}
|
||||
}else {
|
||||
if(!PermUtil.hasRole(m, role)) {
|
||||
|
||||
boolean canAdd = false;
|
||||
if(PermUtil.isBoosterExclusive(role)) {
|
||||
if(PermUtil.isBooster(event.getMember())) {
|
||||
canAdd = true;
|
||||
}
|
||||
}else {
|
||||
canAdd = true;
|
||||
}
|
||||
if(canAdd) {
|
||||
log.info("REACTION TOGGLE (#" + event.getTextChannel().getName() + ") - Adding role " + role.getName() + " too " + m.getUser().getName() + "(" + m.getId() + ")");
|
||||
guild.addRoleToMember(m, role).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class RoleListener extends ListenerAdapter{
|
||||
|
||||
Logger log = Main.log;
|
||||
|
||||
@Override
|
||||
public void onGuildMemberRoleRemove(GuildMemberRoleRemoveEvent event){
|
||||
PermUtil.clearUndeservedRoles(event.getMember());
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.PluginCore;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
import com.github.cage.Cage;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.fpghoti.biscuit.util;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.jcabi.aspects.Async;
|
||||
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
@ -9,6 +13,12 @@ public class PermUtil {
|
|||
public static boolean isAdmin(Member member){
|
||||
if(member.hasPermission(Permission.ADMINISTRATOR)){
|
||||
return true;
|
||||
}else{
|
||||
for(Role role : member.getRoles()){
|
||||
if(role.getName().equalsIgnoreCase(PropertiesRetrieval.getAdminRole())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -18,7 +28,7 @@ public class PermUtil {
|
|||
return true;
|
||||
}else{
|
||||
for(Role role : member.getRoles()){
|
||||
if(role.getName().equalsIgnoreCase("biscuit-key")){
|
||||
if(role.getName().equalsIgnoreCase(PropertiesRetrieval.getModRole())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +36,16 @@ public class PermUtil {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasRole(Member member, String role){
|
||||
for(Role r : member.getRoles()){
|
||||
if(r.getName().equalsIgnoreCase(role)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasRole(Member member, Role role){
|
||||
for(Role r : member.getRoles()){
|
||||
|
@ -36,18 +56,32 @@ public class PermUtil {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canMute(Member member){
|
||||
if(member.hasPermission(Permission.MESSAGE_MANAGE)){
|
||||
|
||||
public static boolean isBooster(Member member) {
|
||||
if(isAdmin(member)) {
|
||||
return true;
|
||||
}else{
|
||||
for(Role role : member.getRoles()){
|
||||
if(role.getName().equalsIgnoreCase("biscuit-key")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for(String r : PropertiesRetrieval.getBoosterRoles()) {
|
||||
if(hasRole(member,r)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBoosterExclusive(Role r) {
|
||||
return Util.containsIgnoreCase(PropertiesRetrieval.getBoostExclusiveRoles(),r.getName());
|
||||
}
|
||||
|
||||
@Async
|
||||
public static void clearUndeservedRoles(Member m) {
|
||||
boolean booster = isBooster(m);
|
||||
for(Role r : m.getRoles()) {
|
||||
if(!booster && isBoosterExclusive(r)) {
|
||||
m.getGuild().removeRoleFromMember(m,r).queue();
|
||||
Main.log.info("BOOST ROLE REMOVED - Member: " + m.getUser().getName() + " (" + m.getId() + ") Role: " + r.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,15 @@ public class Util {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean containsIgnoreCase(String[] list, String s) {
|
||||
for(String l : list) {
|
||||
if(s.equalsIgnoreCase(l)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDeciDigit(String s){
|
||||
int i = 0;
|
||||
|
|
|
@ -25,9 +25,25 @@ CmdChannels = bot,bot2,bot3
|
|||
#Allow users to toggle these roles
|
||||
ToggleRoles = role1,role2,role3
|
||||
|
||||
#Restrict these toggle roles to boosters. Will be removed on boost cancel
|
||||
Boost-Exclusive-Roles = role2,role3
|
||||
|
||||
#Treat these roles like booster.
|
||||
Treat-Like-Booster = Nitro Booster,silver,gold
|
||||
|
||||
#Bot can automatically assign role upon user join
|
||||
UseCustomDefaultRole = true
|
||||
|
||||
#This role will give Biscuit mod commands to users with the role
|
||||
ModRole = biscuit-key
|
||||
|
||||
#This role will give complete admin bot access to users with the role
|
||||
AdminRole = biscuit-admin
|
||||
|
||||
#In these channels, the bot will toggle roles for the ToggleRoles for anyone
|
||||
#who reacts to a message with [Toggle <Role name>]
|
||||
Toggle-Role-React-Channels = roles1,roles2,roles3
|
||||
|
||||
#Does nothing if UseCustomDefaultRole is off
|
||||
DefaultRoleName = Standard
|
||||
|
||||
|
|
Loading…
Reference in New Issue