diff --git a/lists/copypastas.txt b/lists/copypastas.txt index 87e4727..1342eb3 100644 --- a/lists/copypastas.txt +++ b/lists/copypastas.txt @@ -11,6 +11,7 @@ Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ "Read or you die" || Carry on reading && Once there was && Now every week && send this to && break this chain Jake Paul || Jake Paul on a tower about to jump && copy and paste && discord server +"Tag you're it" || funny you opened this because && over the next && first you have && send it to && break the chain // Unicode Bob || /▌ && /\ && This is bob diff --git a/lists/referral_domains.txt b/lists/referral_domains.txt index 625b6fb..1f5a4c5 100644 --- a/lists/referral_domains.txt +++ b/lists/referral_domains.txt @@ -29,6 +29,8 @@ // Ad sites adf.ly +zipansion.com +restorecosm.bid sh.st ceesty.com linkshrink.net @@ -47,6 +49,7 @@ featu.re // Scams +free-gg.com rbxfree.com fortnitevb.com fortnite-special.com @@ -60,4 +63,5 @@ steamreward.com steamspecial.com easter-event.com -steam-wallet-rewards.com \ No newline at end of file +steam-wallet-rewards.com +steam-gift-codes.com \ No newline at end of file diff --git a/lists/safe_domains.txt b/lists/safe_domains.txt index 6fd6d0b..d9eaff7 100644 --- a/lists/safe_domains.txt +++ b/lists/safe_domains.txt @@ -77,6 +77,8 @@ roblox.com capcom-unity.com honeyhunterworld.com +gamespot.com +kiranico.com // Misc google.com @@ -88,11 +90,11 @@ qrserver.com timeanddate.com mit.edu +cnn.com // Whitelist/Common links ygg.fun jagrosh.com mhgh.info giveawaybot.party -discord.pw -kiranico.com \ No newline at end of file +discord.pw \ No newline at end of file diff --git a/pom.xml b/pom.xml index f278eb1..aec47e3 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ net.dv8tion JDA - 3.6.0_359 + 3.6.0_365 com.jagrosh diff --git a/src/main/java/com/jagrosh/vortex/Action.java b/src/main/java/com/jagrosh/vortex/Action.java index 649b4a7..f948871 100644 --- a/src/main/java/com/jagrosh/vortex/Action.java +++ b/src/main/java/com/jagrosh/vortex/Action.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 John Grosh (jagrosh). + * Copyright 2018 John Grosh (jagrosh). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/jagrosh/vortex/Constants.java b/src/main/java/com/jagrosh/vortex/Constants.java index 0b001b4..b87d314 100644 --- a/src/main/java/com/jagrosh/vortex/Constants.java +++ b/src/main/java/com/jagrosh/vortex/Constants.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 John Grosh (jagrosh). + * Copyright 2018 John Grosh (jagrosh). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/jagrosh/vortex/Listener.java b/src/main/java/com/jagrosh/vortex/Listener.java index ba3f5c6..9b487cf 100644 --- a/src/main/java/com/jagrosh/vortex/Listener.java +++ b/src/main/java/com/jagrosh/vortex/Listener.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 John Grosh (john.a.grosh@gmail.com). + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index 7e2e2e8..72d0038 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -117,6 +117,7 @@ new KickCmd(this), new BanCmd(this), new SoftbanCmd(this), + new UnbanCmd(this), new CleanCmd(this), new VoicemoveCmd(this), new VoicekickCmd(this), diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java index 292a2e3..3e023c0 100644 --- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java +++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java @@ -50,7 +50,7 @@ Pattern.CASE_INSENSITIVE); - private static final Pattern REF = Pattern.compile("https?:\\/\\/\\S+(?:\\/ref\\/|[?&#]ref=)\\S+", Pattern.CASE_INSENSITIVE); + private static final Pattern REF = Pattern.compile("https?:\\/\\/\\S+(?:\\/ref\\/|[?&#]ref(?:errer|erral)?=)\\S+", Pattern.CASE_INSENSITIVE); private static final Pattern BASE_URL = Pattern.compile("https?:\\/\\/(?:\\S+\\.)?(\\S+\\.\\S+?)[/?]\\S+", Pattern.CASE_INSENSITIVE); private static final Pattern LINK = Pattern.compile("https?:\\/\\/\\S+", Pattern.CASE_INSENSITIVE); @@ -60,10 +60,6 @@ private static final Logger LOG = LoggerFactory.getLogger("AutoMod"); public static final String RESTORE_MUTE_ROLE_AUDIT = "Restoring Muted Role"; - public static final char[] VALID_DEHOIST_CHAR = {'!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/'}; - public static final String DEHOIST_PREFIX = "\uD82F\uDCA2"; - public static final String DEHOIST_JOINED = "`"+FormatUtil.join("`, `", VALID_DEHOIST_CHAR)+"`"; - private final Vortex vortex; private String[] refLinkList; @@ -234,12 +230,9 @@ if(settings==null || settings.dehoistChar==(char)0 || member.getEffectiveName().charAt(0)>settings.dehoistChar) return; - String newname = AutoMod.DEHOIST_PREFIX+member.getEffectiveName(); - if(newname.length()>32) - newname = newname.substring(0,32); try { - member.getGuild().getController().setNickname(member, newname).reason("Dehoisting").queue(); + OtherUtil.dehoist(member, settings.dehoistChar); } catch(Exception ex) {} } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AntiinviteCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AntiinviteCmd.java index afc9e93..4bf0519 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AntiinviteCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntiinviteCmd.java @@ -1,7 +1,17 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jagrosh.vortex.commands.automod; diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AntirefCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AntirefCmd.java index f5116bd..755b834 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AntirefCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntirefCmd.java @@ -1,7 +1,17 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jagrosh.vortex.commands.automod; diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AutodehoistCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AutodehoistCmd.java index 525f3c1..0634aaf 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AutodehoistCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AutodehoistCmd.java @@ -1,7 +1,17 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jagrosh.vortex.commands.automod; @@ -12,6 +22,7 @@ import com.jagrosh.vortex.automod.AutoMod; import com.jagrosh.vortex.commands.CommandExceptionListener; import com.jagrosh.vortex.database.managers.PunishmentManager; +import com.jagrosh.vortex.utils.OtherUtil; /** * @@ -48,13 +59,13 @@ if(event.getArgs().length()==1) symbol = event.getArgs().charAt(0); else - throw new CommandExceptionListener.CommandErrorException("Provided symbol must be one character of the following: "+AutoMod.DEHOIST_JOINED); + throw new CommandExceptionListener.CommandErrorException("Provided symbol must be one character of the following: "+OtherUtil.DEHOIST_JOINED); boolean allowed = false; - for(char c: AutoMod.VALID_DEHOIST_CHAR) + for(char c: OtherUtil.DEHOIST_ORIGINAL) if(c==symbol) allowed = true; if(!allowed) - throw new CommandExceptionListener.CommandErrorException("Provided symbol must be one character of the following: "+AutoMod.DEHOIST_JOINED); + throw new CommandExceptionListener.CommandErrorException("Provided symbol must be one character of the following: "+OtherUtil.DEHOIST_JOINED); vortex.getDatabase().automod.setDehoistChar(event.getGuild(), symbol); boolean also = vortex.getDatabase().actions.useDefaultSettings(event.getGuild()); diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java index 528959a..913633f 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java @@ -1,7 +1,17 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jagrosh.vortex.commands.automod; @@ -61,7 +71,10 @@ } vortex.getDatabase().automod.setMaxLines(event.getGuild(), maxlines); boolean also = vortex.getDatabase().actions.useDefaultSettings(event.getGuild()); - event.replySuccess("Messages longer than `"+maxlines+"` lines will now be automatically deleted, " + if(maxlines==0) + event.replySuccess("There is now no maximum line limit."); + else + event.replySuccess("Messages longer than `"+maxlines+"` lines will now be automatically deleted, " + "and users will receive strikes for every additional multiple of up to `"+maxlines+"` lines."+(also ? PunishmentManager.DEFAULT_SETUP_MESSAGE : "")); } } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java index 206c25a..41787b1 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java @@ -1,7 +1,17 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jagrosh.vortex.commands.automod; diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java index 92c7978..f9ae9a7 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java @@ -17,6 +17,7 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException; import com.jagrosh.vortex.commands.ModCommand; import net.dv8tion.jda.core.Permission; import com.jagrosh.vortex.utils.ArgsUtil; @@ -52,12 +53,15 @@ event.replyError("Please include at least one user to ban (@mention or ID)!"); return; } - int minutes = args.time/60; - if(minutes < 0) - { - event.replyError("Timed bans cannot be negative time!"); - return; - } + int minutes; + if(args.time < 0) + throw new CommandErrorException("Timed bans cannot be negative time!"); + else if(args.time == 0) + minutes = 0; + else if(args.time > 60) + minutes = (int)Math.round(args.time/60.0); + else + minutes = 1; String reason = LogUtil.auditReasonFormat(event.getMember(), minutes, args.reason); StringBuilder builder = new StringBuilder(); diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java index 9b73e6d..838d0ae 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java @@ -18,6 +18,7 @@ import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException; import com.jagrosh.vortex.commands.ModCommand; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Member; @@ -71,12 +72,15 @@ event.replyError("Please include at least one user to mute (@mention or ID)!"); return; } - int minutes = args.time/60; - if(minutes < 0) - { - event.replyError("Timed bans cannot be negative time!"); - return; - } + int minutes; + if(args.time < 0) + throw new CommandErrorException("Timed mutes cannot be negative time!"); + else if(args.time == 0) + minutes = 0; + else if(args.time > 60) + minutes = (int)Math.round(args.time/60.0); + else + minutes = 1; String reason = LogUtil.auditReasonFormat(event.getMember(), minutes, args.reason); StringBuilder builder = new StringBuilder(); List toMute = new LinkedList<>(); diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java new file mode 100644 index 0000000..835c1d0 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java @@ -0,0 +1,108 @@ +/* + * Copyright 2016 John Grosh (jagrosh). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.jagrosh.vortex.commands.moderation; + +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.commands.ModCommand; +import net.dv8tion.jda.core.Permission; +import com.jagrosh.vortex.utils.ArgsUtil; +import com.jagrosh.vortex.utils.ArgsUtil.ResolvedArgs; +import com.jagrosh.vortex.utils.FormatUtil; +import com.jagrosh.vortex.utils.LogUtil; +import java.util.LinkedList; +import java.util.List; +import net.dv8tion.jda.core.entities.Guild.Ban; + +/** + * + * @author John Grosh (jagrosh) + */ +public class UnbanCmd extends ModCommand +{ + public UnbanCmd(Vortex vortex) + { + super(vortex, Permission.BAN_MEMBERS); + this.name = "unban"; + this.arguments = "<@users> [reason]"; + this.help = "unbans users"; + this.botPermissions = new Permission[]{Permission.BAN_MEMBERS}; + this.guildOnly = true; + } + + @Override + protected void execute(CommandEvent event) + { + ResolvedArgs args = ArgsUtil.resolve(event.getArgs(), event.getGuild()); + if(args.isEmpty()) + { + event.replyError("Please include at least one user to unban (@mention or ID)!"); + return; + } + String reason = LogUtil.auditReasonFormat(event.getMember(), args.reason); + StringBuilder builder = new StringBuilder(); + + event.getGuild().getBanList().queue(list -> + { + List toUnban = new LinkedList<>(); + args.members.forEach(m -> args.users.add(m.getUser())); + args.users.forEach(u -> + { + Ban ban = list.stream().filter(b -> b.getUser().getIdLong()==u.getIdLong()).findFirst().orElse(null); + if(ban==null) + builder.append("\n").append(event.getClient().getError()).append(" ").append(FormatUtil.formatUser(u)).append(" is not banned!"); + else + toUnban.add(ban); + }); + args.ids.forEach(id -> + { + Ban ban = list.stream().filter(b -> b.getUser().getIdLong()==id).findFirst().orElse(null); + if(ban==null) + builder.append("\n").append(event.getClient().getError()).append(" <@").append(id).append("> is not banned!"); + else + toUnban.add(ban); + }); + args.unresolved.forEach(un -> builder.append("\n").append(event.getClient().getWarning()).append(" Could not resolve `").append(un).append("` to a user ID")); + + if(toUnban.isEmpty()) + { + event.reply(builder.toString()); + return; + } + + if(toUnban.size() > 5) + event.reactSuccess(); + + for(int i=0; i + { + builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully unbanned ").append(FormatUtil.formatUser(ban.getUser())); + if(last) + event.reply(builder.toString()); + }, f -> + { + builder.append("\n").append(event.getClient().getError()).append(" Failed to unban ").append(FormatUtil.formatUser(ban.getUser())); + if(last) + event.reply(builder.toString()); + }); + } + + }, f -> event.replyError("Failed to retreive the ban list.")); + } +} diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java index e204a3a..350317c 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java @@ -60,8 +60,6 @@ String[] parts = event.getArgs().split("\\s+", 3); if(parts.length<2) throw new CommandExceptionListener.CommandErrorException("Please include a number of strikes and an action to perform!"+SETTING_STRIKES); - if(vortex.getDatabase().actions.getAllPunishments(event.getGuild()).size()>=PunishmentManager.MAX_SET) - throw new CommandExceptionListener.CommandErrorException("This server already has "+PunishmentManager.MAX_SET+" punishments set up; please remove some before adding more."); int numstrikes; try { @@ -77,6 +75,10 @@ event.replyError("`` must be between 1 and "+PunishmentManager.MAX_STRIKES+"!"+SETTING_STRIKES); return; } + + if(!parts[1].equalsIgnoreCase("none") && vortex.getDatabase().actions.getAllPunishments(event.getGuild()).size()>=PunishmentManager.MAX_SET) + throw new CommandExceptionListener.CommandErrorException("This server already has "+PunishmentManager.MAX_SET+" punishments set up; please remove some before adding more."); + String successMessage; switch(parts[1].toLowerCase()) { diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java index 4f7422b..cd408eb 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java @@ -19,6 +19,7 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.vortex.automod.AutoMod; import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException; +import com.jagrosh.vortex.utils.OtherUtil; import java.util.List; import java.util.stream.Collectors; import net.dv8tion.jda.core.Permission; @@ -47,28 +48,21 @@ { char symbol; if(event.getArgs().isEmpty()) - symbol = AutoMod.VALID_DEHOIST_CHAR[0]; + symbol = OtherUtil.DEHOIST_ORIGINAL[0]; else if(event.getArgs().length()==1) symbol = event.getArgs().charAt(0); else - throw new CommandErrorException("Provided symbol must be one character of the following: "+AutoMod.DEHOIST_JOINED); + throw new CommandErrorException("Provided symbol must be one character of the following: "+OtherUtil.DEHOIST_JOINED); boolean allowed = false; - for(char c: AutoMod.VALID_DEHOIST_CHAR) + for(char c: OtherUtil.DEHOIST_ORIGINAL) if(c==symbol) allowed = true; if(!allowed) - throw new CommandErrorException("Provided symbol must be one character of the following: "+AutoMod.DEHOIST_JOINED); - List toDehoist = event.getGuild().getMembers().stream() - .filter(m -> event.getSelfMember().canInteract(m) && m.getEffectiveName().charAt(0)<=symbol) - .collect(Collectors.toList()); - toDehoist.forEach(m -> - { - String newname = AutoMod.DEHOIST_PREFIX+m.getEffectiveName(); - if(newname.length()>32) - newname = newname.substring(0,32); - event.getGuild().getController().setNickname(m, newname).queue(); - }); - event.replySuccess("Dehoisting `"+toDehoist.size()+"` members with names starting with `"+symbol+"` or higher."); + throw new CommandErrorException("Provided symbol must be one character of the following: "+OtherUtil.DEHOIST_JOINED); + + long count = event.getGuild().getMembers().stream().filter(m -> OtherUtil.dehoist(m, symbol)).count(); + + event.replySuccess("Dehoisting `"+count+"` members with names starting with `"+symbol+"` or higher."); } } diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java index dc9bc2c..e0afa39 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java @@ -78,9 +78,9 @@ event.getChannel().sendTyping().queue(); event.getGuild().getInvites().queue(list -> { - List toPrune = list.stream().filter(i -> !i.getInviter().isBot() && i.getUses()<=uses).collect(Collectors.toList()); + List toPrune = list.stream().filter(i -> i.getInviter()!=null && !i.getInviter().isBot() && i.getUses()<=uses).collect(Collectors.toList()); toPrune.forEach(i -> i.delete().queue()); - event.replySuccess("Deleted `"+toPrune.size()+"` invites with `"+uses+"` or fewer uses."); + event.replySuccess("Deleting `"+toPrune.size()+"` invites with `"+uses+"` or fewer uses."); }); } diff --git a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java index 6fadf9b..d736136 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java @@ -42,7 +42,7 @@ { public final static int PREFIX_MAX_LENGTH = 40; private static final String SETTINGS_TITLE = "\uD83D\uDCCA Server Settings"; - private static final ZoneId DEFAULT_TIMEZONE = ZoneId.of("GMT+4"); + private static final ZoneId DEFAULT_TIMEZONE = ZoneId.of("GMT-4"); public final static SQLColumn GUILD_ID = new LongColumn("GUILD_ID",false,0L,true); public final static SQLColumn MOD_ROLE_ID = new LongColumn("MOD_ROLE_ID",false,0L); diff --git a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java index 18707f5..6ab23ae 100644 --- a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java +++ b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java @@ -278,10 +278,13 @@ { vortex.getDatabase().tempmutes.removeMute(guild, ale.getTargetIdLong()); } - modlog.sendMessage(FormatUtil.filterEveryone(minutes > 0 ? + String msg = FormatUtil.filterEveryone(minutes > 0 ? LogUtil.modlogTimeFormat(ale.getCreationTime(), timezone, getCaseNumber(modlog), mod, act, minutes, target, reason) : - LogUtil.modlogUserFormat(ale.getCreationTime(), timezone, getCaseNumber(modlog), mod, act, target, reason))) - .queue(act==Action.BAN ? m -> banLogCache.put(banCacheKey, m) : null); + LogUtil.modlogUserFormat(ale.getCreationTime(), timezone, getCaseNumber(modlog), mod, act, target, reason)); + if(act==Action.BAN) + banLogCache.put(banCacheKey, modlog.sendMessage(msg).complete()); + else + modlog.sendMessage(msg).queue(); } } } diff --git a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java index 52b1393..93924d0 100644 --- a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java @@ -35,6 +35,30 @@ { private final static Logger LOG = LoggerFactory.getLogger(OtherUtil.class); + public final static char[] DEHOIST_ORIGINAL = {'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/'}; + public final static char[] DEHOIST_REPLACEMENTS = {'\u01C3', '\u201C', '\u2D4C', '\uFF04', '\u2105', '\u214B', '\u2018', '\u2768', '\u2769', '\u2217', '\u2722', '\u201A', '\u2013', '\uFBB3', '\u2044'}; + public final static String DEHOIST_JOINED = "`"+FormatUtil.join("`, `", DEHOIST_ORIGINAL)+"`"; + + public final static boolean dehoist(Member m, char symbol) + { + if(!m.getGuild().getSelfMember().canInteract(m)) + return false; + if(m.getEffectiveName().charAt(0)>symbol) + return false; + + String newname = m.getEffectiveName(); + for(int i=0; i