diff --git a/lists/copypastas.txt b/lists/copypastas.txt index bb30d4a..9d7be12 100644 --- a/lists/copypastas.txt +++ b/lists/copypastas.txt @@ -1,29 +1,29 @@ -// Copypastas -// Bits of text that tend to be copied and pasted - -// False Discord PSA -False PSA || out for a Discord && going around && those who accept && send this to as many && if you see this -Fake Hacker PSA || not accept friend request from && hackers && tell everyone && copy && paste -Fake Discord shutdown || discord && clos && populated && active && please send && copy && paste && deleted without hesitation - -// Share or else -Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯ -Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏ -Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ -"Read or you die" || Carry on reading && Once there was && Now every week && send this to && copy and paste -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 -Lennipede || ╚═(███)═╝ && Lenn -Doge || ▐▄█▀▒▒▒▒▄▀█▄ && ▐▄█▄█▌▄▒▀▒ && ▒▀▀▄▄▒▒▒▄▒ - -// Text -Navy Seals || say about me && ll have you know I && I am trained && Think again && Not only am I extensively trained && kid -Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftly woven && heavily && intellectual capacity && cryptic reference -Shrek || years old && is love && is life && spread && push against && straight in the - -// Scams -Fake Libra Site || getlⅰbra.tech -Fake Libra Site (2) || buylⅰbra.τech +// Copypastas +// Bits of text that tend to be copied and pasted + +// False Discord PSA +False PSA || out for a Discord && going around && those who accept && send this to as many && if you see this +Fake Hacker PSA || not accept && friend request from && hacker && tell everyone && copy && paste +Fake Discord shutdown || discord && clos && populated && active && please send && copy && paste && deleted without hesitation + +// Share or else +Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯ +Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏ +Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ +Memecat (2) || Λ_Λ && ˇωˇ && > ⌒ヽ +"Read or you die" || Carry on reading && Once there was && Now every week && send this to && copy and paste +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 +Lennipede || ╚═(███)═╝ && Lenn +Doge || ▐▄█▀▒▒▒▒▄▀█▄ && ▐▄█▄█▌▄▒▀▒ && ▒▀▀▄▄▒▒▒▄▒ + +// Text +Navy Seals || say about me && ll have you know I && I am trained && Think again && Not only am I extensively trained && kid +Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftly woven && heavily && intellectual capacity && cryptic reference +Shrek || years old && is love && is life && spread && push against && straight in the + +// Scams +Fake Libra Site || lⅰbra diff --git a/pom.xml b/pom.xml index c910073..b9bc8e9 100644 --- a/pom.xml +++ b/pom.xml @@ -24,12 +24,12 @@ net.dv8tion JDA - 4.1.1_110 + 4.2.0_181 com.jagrosh jda-utilities - 3.0.2 + 3.0.4 pom diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index ae81aac..5b2eac6 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -44,13 +44,16 @@ import com.jagrosh.vortex.utils.OtherUtil; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; +import java.util.Arrays; import java.util.EnumSet; import java.util.concurrent.TimeUnit; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.ChannelType; +import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.exceptions.PermissionException; +import net.dv8tion.jda.api.requests.restaction.MessageAction; import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder; import net.dv8tion.jda.api.sharding.ShardManager; import net.dv8tion.jda.api.utils.cache.CacheFlag; @@ -162,6 +165,7 @@ new AnnounceCmd(), new AuditCmd(), new DehoistCmd(), + new ExportCmd(this), new InvitepruneCmd(this), new LookupCmd(this), @@ -183,6 +187,7 @@ .setDiscordBotsKey(config.getString("listing.discord-bots")) //.setCarbonitexKey(config.getString("listing.carbon")) .build(); + MessageAction.setDefaultMentions(Arrays.asList(Message.MentionType.EMOTE, Message.MentionType.CHANNEL)); shards = new DefaultShardManagerBuilder() .setShardsTotal(config.getInt("shards-total")) .setToken(config.getString("bot-token")) @@ -193,6 +198,7 @@ .setRequestTimeoutRetry(true) .setDisabledCacheFlags(EnumSet.of(CacheFlag.EMOTE, CacheFlag.ACTIVITY)) //TODO: dont disable GAME .setSessionController(new BlockingSessionController()) + .build(); modlog.start(); @@ -285,8 +291,10 @@ return false; if(Constants.OWNER_ID.equals(g.getOwnerId())) return false; - int botcount = (int)g.getMemberCache().stream().filter(m -> m.getUser().isBot()).count(); - if(g.getMemberCache().size()-botcount<15 || (botcount>20 && ((double)botcount/g.getMemberCache().size())>0.5)) + int botcount = (int) g.getMemberCache().stream().filter(m -> m.getUser().isBot()).count(); + int totalcount = (int) g.getMemberCache().size(); + int humancount = totalcount - botcount; + if(humancount < 30 || botcount > humancount) { if(database.settings.hasSettings(g)) return false; diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java index 43be3d7..ec95853 100644 --- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java +++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java @@ -52,7 +52,7 @@ */ public class AutoMod { - private static final Pattern INVITES = Pattern.compile("discord\\s?(?:(?:\\.|dot|\\(\\.\\)|\\(dot\\))\\s?gg|app\\s?\\.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})", + private static final Pattern INVITES = Pattern.compile("discord\\s?(?:(?:\\.|dot|\\(\\.\\)|\\(dot\\))\\s?gg|(?:app)?\\s?\\.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})", Pattern.CASE_INSENSITIVE); private static final Pattern REF = Pattern.compile("https?:\\/\\/\\S+(?:\\/ref\\/|[?&#]ref(?:errer|erral)?=)\\S+", Pattern.CASE_INSENSITIVE); @@ -204,11 +204,11 @@ private boolean shouldPerformAutomod(Member member, TextChannel channel) { // ignore users not in the guild - if(member==null || member.getGuild()==null) + if(member==null) return false; // ignore broken guilds - if(member.getGuild().getSelfMember()==null || member.getGuild().getOwner()==null) + if(member.getGuild().getOwner()==null) return false; // ignore bots @@ -273,11 +273,9 @@ return; // check the channel for channel-specific settings - boolean preventSpam = message.getTextChannel().getTopic()==null - || !message.getTextChannel().getTopic().toLowerCase().contains("{spam}"); - boolean preventInvites = (message.getTextChannel().getTopic()==null - || !message.getTextChannel().getTopic().toLowerCase().contains("{invites}")) - && settings.inviteStrikes > 0; + String topic = message.getTextChannel().getTopic(); + boolean preventSpam = topic==null || !topic.toLowerCase().contains("{spam}"); + boolean preventInvites = (topic==null || !topic.toLowerCase().contains("{invites}")) && settings.inviteStrikes > 0; List inviteWhitelist = !preventInvites ? Collections.emptyList() : vortex.getDatabase().inviteWhitelist.readWhitelist(message.getGuild()); diff --git a/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java b/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java index fdd7873..df70ce0 100644 --- a/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java +++ b/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java @@ -18,6 +18,7 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.command.CommandListener; +import com.jagrosh.vortex.utils.FormatUtil; import com.jagrosh.vortex.utils.Usage; import net.dv8tion.jda.api.entities.ChannelType; import org.slf4j.Logger; @@ -36,9 +37,9 @@ public void onCommandException(CommandEvent event, Command command, Throwable throwable) { if (throwable instanceof CommandErrorException) - event.replyError(throwable.getMessage()); + event.replyError(FormatUtil.filterEveryone(throwable.getMessage())); else if (throwable instanceof CommandWarningException) - event.replyWarning(throwable.getMessage()); + event.replyWarning(FormatUtil.filterEveryone(throwable.getMessage())); else log.error("An exception occurred in a command: "+command, throwable); } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java index dec757a..a7c609f 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java @@ -21,6 +21,7 @@ import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.AutomodManager; import com.jagrosh.vortex.database.managers.PunishmentManager; +import com.jagrosh.vortex.utils.FormatUtil; /** * @@ -61,7 +62,7 @@ numstrikes = 0; else { - event.replyError("`"+event.getArgs()+"` is not a valid integer!"); + event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!")); return; } } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java index 18cea16..d69f155 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java @@ -21,6 +21,7 @@ import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.AutomodManager; import com.jagrosh.vortex.database.managers.PunishmentManager; +import com.jagrosh.vortex.utils.FormatUtil; /** * @@ -61,7 +62,7 @@ numstrikes = 0; else { - event.replyError("`"+event.getArgs()+"` is not a valid integer!"); + event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!")); return; } } 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 e1953c3..20b5c71 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AntiinviteCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntiinviteCmd.java @@ -21,6 +21,7 @@ import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.AutomodManager; import com.jagrosh.vortex.database.managers.PunishmentManager; +import com.jagrosh.vortex.utils.FormatUtil; /** * @@ -62,7 +63,7 @@ numstrikes = 0; else { - event.replyError("`"+event.getArgs()+"` is not a valid integer!"); + event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!")); return; } } 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 27e352e..6493911 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AntirefCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntirefCmd.java @@ -21,6 +21,7 @@ import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.AutomodManager; import com.jagrosh.vortex.database.managers.PunishmentManager; +import com.jagrosh.vortex.utils.FormatUtil; /** * @@ -61,7 +62,7 @@ numstrikes = 0; else { - event.replyError("`"+event.getArgs()+"` is not a valid integer!"); + event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!")); return; } } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java index a1536fc..0c34066 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java @@ -22,6 +22,7 @@ import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.automod.Filter; import com.jagrosh.vortex.database.managers.PremiumManager; +import com.jagrosh.vortex.utils.FormatUtil; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.MessageEmbed.Field; @@ -113,8 +114,8 @@ Filter filter = Filter.parseFilter(parts[0], strikes, parts[2]); if(vortex.getDatabase().filters.addFilter(event.getGuild(), filter)) { - event.replySuccess("Filter *" + filter.name + "* (`" + filter.strikes + " " + Action.STRIKE.getEmoji() - + "`) successfully created with filtered terms:\n" + filter.printContentEscaped()); + event.replySuccess(FormatUtil.filterEveryone("Filter *" + filter.name + "* (`" + filter.strikes + " " + Action.STRIKE.getEmoji() + + "`) successfully created with filtered terms:\n" + filter.printContentEscaped())); } else { @@ -153,11 +154,11 @@ Filter filter = vortex.getDatabase().filters.deleteFilter(event.getGuild(), event.getArgs()); if(filter == null) { - event.replyError("Filter `" + event.getArgs() + "` could not be found"); + event.replyError(FormatUtil.filterEveryone("Filter `" + event.getArgs() + "` could not be found")); } else { - event.replySuccess("Removed filter `" + filter.name + "`"); + event.replySuccess(FormatUtil.filterEveryone("Removed filter `" + filter.name + "`")); } } } @@ -181,7 +182,7 @@ Field field = vortex.getDatabase().filters.getFiltersDisplay(event.getGuild()); if(field == null) { - event.replyWarning("There are no filters for **" + event.getGuild().getName() + "**"); + event.replyWarning(FormatUtil.filterEveryone("There are no filters for **" + event.getGuild().getName() + "**")); return; } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/IgnoreCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/IgnoreCmd.java index 73c8439..1612e49 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/IgnoreCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/IgnoreCmd.java @@ -81,13 +81,13 @@ List roles = FinderUtil.findRoles(event.getArgs(), event.getGuild()); if(roles.isEmpty()) - event.replyError("No roles or text channels found for `"+event.getArgs()+"`"); + event.replyError(FormatUtil.filterEveryone("No roles or text channels found for `"+event.getArgs()+"`")); else if (roles.size()==1) { vortex.getDatabase().ignores.ignore(roles.get(0)); - event.replySuccess("Automod is now ignoring role `"+roles.get(0).getName()+"`"); + event.replySuccess(FormatUtil.filterEveryone("Automod is now ignoring role `"+roles.get(0).getName()+"`")); } else - event.replyWarning(FormatUtil.listOfRoles(roles, event.getArgs())); + event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfRoles(roles, event.getArgs()))); } } 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 0d566f6..65c84f2 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java @@ -20,6 +20,7 @@ import net.dv8tion.jda.api.Permission; import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.PunishmentManager; +import com.jagrosh.vortex.utils.FormatUtil; /** * @@ -60,7 +61,7 @@ maxlines = 0; else { - event.replyError("`"+event.getArgs()+"` is not a valid integer!"); + event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!")); return; } } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/ResolvelinksCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/ResolvelinksCmd.java index 30b2d7f..cde0f18 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/ResolvelinksCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/ResolvelinksCmd.java @@ -17,7 +17,6 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.vortex.Constants; import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.PremiumManager; import net.dv8tion.jda.api.Permission; 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 0110f36..e8352be 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java @@ -71,18 +71,18 @@ List roles = FinderUtil.findRoles(event.getArgs(), event.getGuild()); if(roles.isEmpty()) - event.replyError("No roles or text channels found for `"+event.getArgs()+"`"); + event.replyError(FormatUtil.filterEveryone("No roles or text channels found for `"+event.getArgs()+"`")); else if (roles.size()==1) { if(vortex.getDatabase().ignores.unignore(roles.get(0))) event.replySuccess("Automod is no longer ignoring role `"+roles.get(0).getName()+"`"); else - event.replyError("Automod was not ignoring role `"+roles.get(0).getName()+"`" + event.replyError(FormatUtil.filterEveryone("Automod was not ignoring role `"+roles.get(0).getName()+"`" + "\n"+event.getClient().getWarning()+" If this role is still listed when using `"+event.getClient().getPrefix()+"ignore`:" + "\n`[can't interact]` - the role is above "+event.getSelfUser().getName()+"'s highest role; try moving the '"+event.getSelfUser().getName()+"' role higher" - + "\n`[elevated perms]` - the role has one of the following permissions: Kick Members, Ban Members, Manage Server, Manage Messages, Administrator"); + + "\n`[elevated perms]` - the role has one of the following permissions: Kick Members, Ban Members, Manage Server, Manage Messages, Administrator")); } else - event.replyWarning(FormatUtil.listOfRoles(roles, event.getArgs())); + event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfRoles(roles, event.getArgs()))); } } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/WhitelistInvitesCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/WhitelistInvitesCmd.java index fa4ea31..fbaf84d 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/WhitelistInvitesCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/WhitelistInvitesCmd.java @@ -18,6 +18,7 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.utils.FormatUtil; import net.dv8tion.jda.api.Permission; import java.util.ArrayList; @@ -74,8 +75,8 @@ return; } List currentWL = vortex.getDatabase().inviteWhitelist.readWhitelist(event.getGuild()); - event.replySuccess("Whitelisted Guild IDs:\n" + (currentWL.isEmpty() ? "None" : - "`" + currentWL.stream().map(String::valueOf).collect(Collectors.joining("`, `")) + "`")); + event.replySuccess(FormatUtil.filterEveryone("Whitelisted Guild IDs:\n" + (currentWL.isEmpty() ? "None" : + "`" + currentWL.stream().map(String::valueOf).collect(Collectors.joining("`, `")) + "`"))); } private void handleAdd(CommandEvent event, String[] args) diff --git a/src/main/java/com/jagrosh/vortex/commands/general/RoleinfoCmd.java b/src/main/java/com/jagrosh/vortex/commands/general/RoleinfoCmd.java new file mode 100644 index 0000000..63366a1 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/commands/general/RoleinfoCmd.java @@ -0,0 +1,100 @@ +/* + * 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.general; + +import java.time.format.DateTimeFormatter; +import com.jagrosh.jdautilities.command.Command; +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jdautilities.commons.utils.FinderUtil; +import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException; +import com.jagrosh.vortex.utils.FormatUtil; +import java.util.List; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.MessageBuilder; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.Role; + +/** + * + * @author John Grosh (jagrosh) + */ +public class RoleinfoCmd extends Command +{ + private final static String LINESTART = "\u25AB"; // ▫ + private final static String ROLE_EMOJI = "\uD83C\uDFAD"; // 🎭 + + public RoleinfoCmd() + { + this.name = "roleinfo"; + this.aliases = new String[]{"rinfo","rankinfo"}; + this.help = "shows info about a role"; + this.arguments = ""; + this.guildOnly = true; + this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; + } + + @Override + protected void execute(CommandEvent event) + { + Role role; + if(event.getArgs().isEmpty()) + throw new CommandErrorException("Please provide the name of a role!"); + else + { + List found = FinderUtil.findRoles(event.getArgs(), event.getGuild()); + if(found.isEmpty()) + { + event.replyError("I couldn't find the role you were looking for!"); + return; + } + else if(found.size()>1) + { + event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfRoles(found, event.getArgs()))); + return; + } + else + { + role = found.get(0); + } + } + + String title = ROLE_EMOJI + " Information about **"+role.getName()+"**:"; + List list = role.isPublicRole() ? event.getGuild().getMembers() : event.getGuild().getMembersWithRoles(role); + StringBuilder desr = new StringBuilder(LINESTART+"ID: **"+role.getId()+"**\n" + + LINESTART+"Creation: **"+role.getTimeCreated().format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n" + + LINESTART+"Position: **"+role.getPosition()+"**\n" + + LINESTART+"Color: **#"+(role.getColor()==null ? "000000" : Integer.toHexString(role.getColor().getRGB()).toUpperCase().substring(2))+"**\n" + + LINESTART+"Mentionable: **"+role.isMentionable()+"**\n" + + LINESTART+"Hoisted: **"+role.isHoisted()+"**\n" + + LINESTART+"Managed: **"+role.isManaged()+"**\n" + + LINESTART+"Permissions: "); + if(role.getPermissions().isEmpty()) + desr.append("None"); + else + desr.append(role.getPermissions().stream().map(p -> "`, `"+p.getName()).reduce("", String::concat).substring(3)).append("`"); + desr.append("\n").append(LINESTART).append("Members: **").append(list.size()).append("**\n"); + if(list.size()*24<=2048-desr.length()) + list.forEach(m -> desr.append("<@").append(m.getUser().getId()).append("> ")); + + event.reply(new MessageBuilder() + .append(FormatUtil.filterEveryone(title)) + .setEmbed(new EmbedBuilder() + .setDescription(desr.toString().trim()) + .setColor(role.getColor()).build()) + .build()); + } +} diff --git a/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java b/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java index a90b39f..68b3898 100644 --- a/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java @@ -69,7 +69,7 @@ } else if(found.size()>1) { - event.replyWarning(FormatUtil.listOfMember(found, event.getArgs())); + event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfMember(found, event.getArgs()))); return; } else diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/CheckCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/CheckCmd.java index f19f07b..d3dd86c 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/CheckCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/CheckCmd.java @@ -78,7 +78,7 @@ } catch(Exception ex) { - event.replyError("Could not find a user `"+event.getArgs()+"`"); + event.replyError(FormatUtil.filterEveryone("Could not find a user `"+event.getArgs()+"`")); } } @@ -104,6 +104,6 @@ + Action.TEMPMUTE.getEmoji() + " Mute Time Remaining: " + (minutesMuted <= 0 ? "N/A" : FormatUtil.secondsToTime(minutesMuted * 60)) + "\n" + Action.BAN.getEmoji() + " Banned: **" + (ban==null ? "No**" : "Yes** (`" + ban.getReason() + "`)") + "\n" + Action.TEMPBAN.getEmoji() + " Ban Time Remaining: " + (minutesBanned <= 0 ? "N/A" : FormatUtil.secondsToTime(minutesBanned * 60)); - event.replySuccess(str); + event.replySuccess(FormatUtil.filterEveryone(str)); } } diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/ReasonCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/ReasonCmd.java index 9714e28..e728dea 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/ReasonCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/ReasonCmd.java @@ -38,7 +38,6 @@ @Override protected void execute(CommandEvent event) { - int caseNum; String[] parts = event.getArgs().split("\\s+", 2); String str; diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/VoicemoveCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/VoicemoveCmd.java index d21667d..547e1c9 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/VoicemoveCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/VoicemoveCmd.java @@ -66,7 +66,7 @@ } if(list.size()>1) { - event.replyWarning(FormatUtil.listOfVoice(list, event.getArgs())); + event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfVoice(list, event.getArgs()))); return; } vc = list.get(0); @@ -91,7 +91,7 @@ } catch(Exception e) { - event.replyWarning("I could not connect to **"+vc.getName()+"**"); + event.replyWarning(FormatUtil.filterEveryone("I could not connect to **"+vc.getName()+"**")); return; } vortex.getEventWaiter().waitForEvent(GuildVoiceMoveEvent.class, diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/ExportCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/ExportCmd.java deleted file mode 100644 index 11210bd..0000000 --- a/src/main/java/com/jagrosh/vortex/commands/owner/ExportCmd.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2020 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.owner; - -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.vortex.Vortex; -import net.dv8tion.jda.api.Permission; -import org.json.JSONObject; - -/** - * - * @author John Grosh (john.a.grosh@gmail.com) - */ -public class ExportCmd extends Command -{ - private final Vortex vortex; - - public ExportCmd(Vortex vortex) - { - this.vortex = vortex; - this.name = "export"; - this.arguments = ""; - this.help = "exports all server data as json"; - this.category = new Category("Tools"); - this.userPermissions = new Permission[]{Permission.MESSAGE_ATTACH_FILES}; - this.ownerCommand = true; - } - - @Override - protected void execute(CommandEvent event) - { - long gid; - try - { - gid = Long.parseLong(event.getArgs()); - } - catch(NumberFormatException ex) - { - event.reactError(); - return; - } - JSONObject obj = new JSONObject(); - - } -} diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java new file mode 100644 index 0000000..979be27 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java @@ -0,0 +1,65 @@ +/* + * Copyright 2020 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.tools; + +import com.jagrosh.jdautilities.command.Command; +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.database.Database; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.Guild; +import org.json.JSONObject; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class ExportCmd extends Command +{ + private final Vortex vortex; + + public ExportCmd(Vortex vortex) + { + this.vortex = vortex; + this.name = "export"; + this.help = "exports all server data as json"; + this.category = new Category("Tools"); + this.botPermissions = new Permission[]{Permission.MESSAGE_ATTACH_FILES}; + this.userPermissions = new Permission[]{Permission.ADMINISTRATOR}; + this.cooldown = 60*30; + this.cooldownScope = CooldownScope.GUILD; + this.guildOnly = true; + } + + @Override + protected void execute(CommandEvent event) + { + Guild g = event.getGuild(); + Database db = vortex.getDatabase(); + JSONObject obj = new JSONObject() + .put("automod", db.automod.getSettingsJson(g)) + .put("settings", db.settings.getSettingsJson(g)) + .put("ignores", db.ignores.getIgnoresJson(g)) + .put("strikes", db.strikes.getAllStrikesJson(g)) + .put("punishments", db.actions.getAllPunishmentsJson(g)) + .put("tempmutes", db.tempmutes.getAllMutesJson(g)) + .put("tempbans", db.tempbans.getAllBansJson(g)) + .put("inviteWhitelist", db.inviteWhitelist.getWhitelistJson(g)) + .put("filters", db.filters.getFiltersJson(g)) + .put("premium", db.premium.getPremiumInfoJson(g)); + event.getChannel().sendFile(obj.toString(1).getBytes(), "vortex_data_" + g.getId() + ".json").queue(); + } +} diff --git a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java index d46cb22..38feb57 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java @@ -26,6 +26,7 @@ import java.sql.SQLException; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.MessageEmbed.Field; +import org.json.JSONObject; /** * @@ -112,6 +113,26 @@ /*+ "\u200B"*/, true); } + public JSONObject getSettingsJson(Guild guild) + { + AutomodSettings settings = getSettings(guild); + return new JSONObject() + .put("copypastaStrikes", settings.copypastaStrikes) + .put("dehoistChar", ""+settings.dehoistChar) + .put("dupeDeleteThresh", settings.dupeDeleteThresh) + .put("dupeStrikeThresh", settings.dupeStrikeThresh) + .put("dupeStrikes", settings.dupeStrikes) + .put("everyoneStrikes", settings.everyoneStrikes) + .put("inviteStrikes", settings.inviteStrikes) + .put("maxLines", settings.maxLines) + .put("maxMentions", settings.maxMentions) + .put("maxRoleMentions", settings.maxRoleMentions) + .put("raidmodeNumber", settings.raidmodeNumber) + .put("raidmodeTime", settings.raidmodeTime) + .put("refStrikes", settings.refStrikes) + .put("resolveUrls", settings.resolveUrls); + } + public boolean hasSettings(Guild guild) { return read(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> {return rs.next();}); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java b/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java index 96b79e5..d91ae0f 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java @@ -27,6 +27,7 @@ import java.util.List; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.MessageEmbed.Field; +import org.json.JSONObject; /** * @@ -90,6 +91,14 @@ return new Field(SETTINGS_TITLE, sb.toString().trim(), true); } + public JSONObject getFiltersJson(Guild guild) + { + List filters = getFilters(guild); + JSONObject obj = new JSONObject(); + filters.forEach(f -> obj.put(f.name, new JSONObject().put("strikes",f.strikes).put("content", f.printContent()))); + return obj; + } + public boolean addFilter(Guild guild, Filter filter) { String shortname = shortnameOf(filter.name); 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 8b0500a..b58e5ad 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java @@ -34,6 +34,7 @@ import net.dv8tion.jda.api.entities.MessageEmbed.Field; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.TextChannel; +import org.json.JSONObject; /** * @@ -103,6 +104,22 @@ + "\nTimezone: **"+settings.timezone+"**\n\u200B", true); } + public JSONObject getSettingsJson(Guild guild) + { + GuildSettings settings = getSettings(guild); + return new JSONObject() + .put("avatarlog", settings.avatarlog) + .put("messagelog", settings.messagelog) + .put("modRole", settings.modRole) + .put("modlog", settings.modlog) + .put("muteRole", settings.muteRole) + .put("prefix", settings.prefix) + .put("raidMode", settings.raidMode) + .put("serverlog", settings.serverlog) + .put("timezone", settings.timezone) + .put("voicelog", settings.voicelog); + } + public boolean hasSettings(Guild guild) { return read(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> {return rs.next();}); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java b/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java index 1920919..0037d96 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java @@ -29,6 +29,7 @@ import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.TextChannel; +import org.json.JSONArray; /** * @@ -47,6 +48,13 @@ super(connector, "IGNORED"); } + public JSONArray getIgnoresJson(Guild guild) + { + JSONArray array = new JSONArray(); + getIgnores(guild).forEach(id -> array.put(id)); + return array; + } + public boolean isIgnored(TextChannel tc) { return getIgnores(tc.getGuild()).contains(tc.getIdLong()); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java b/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java index 9656c35..bcc8928 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java @@ -19,6 +19,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.json.JSONArray; public class InviteWhitelistManager extends DataManager { @@ -131,6 +132,14 @@ cache.put(guild.getIdLong(), whitelist); return whitelist; } + + public JSONArray getWhitelistJson(Guild guild) + { + List list = readWhitelist(guild); + JSONArray arr = new JSONArray(); + list.forEach(id -> arr.put(id)); + return arr; + } private void invalidateCache(Guild guild) { diff --git a/src/main/java/com/jagrosh/vortex/database/managers/PremiumManager.java b/src/main/java/com/jagrosh/vortex/database/managers/PremiumManager.java index 8eaf834..56cfd41 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/PremiumManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/PremiumManager.java @@ -30,6 +30,7 @@ import java.util.LinkedList; import java.util.List; import net.dv8tion.jda.api.entities.Guild; +import org.json.JSONObject; /** * @@ -72,6 +73,14 @@ }); } + public JSONObject getPremiumInfoJson(Guild guild) + { + PremiumInfo info = getPremiumInfo(guild); + return new JSONObject() + .put("level", info.level.name()) + .put("until", info.until == null ? 0 : info.until.getEpochSecond()); + } + public void addPremiumForever(Guild guild, Level level) { readWrite(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> diff --git a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java index 071034b..dd6bbed 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java @@ -30,6 +30,7 @@ import java.util.stream.Collectors; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.MessageEmbed.Field; +import org.json.JSONObject; /** * @@ -172,6 +173,14 @@ return new Field(STRIKES_TITLE, sb.toString().trim(), true); } + public JSONObject getAllPunishmentsJson(Guild guild) + { + JSONObject obj = new JSONObject(); + getAllPunishments(guild).forEach(p -> obj.put(Integer.toString(p.numStrikes), + new JSONObject().put("action", p.action.toString()).put("time", p.time))); + return obj; + } + public class Punishment { public final Action action; diff --git a/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java b/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java index 29e9a2a..a14ac9d 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java @@ -23,6 +23,7 @@ import java.util.Map; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; +import org.json.JSONObject; /** * @@ -108,4 +109,11 @@ return map; }); } + + public JSONObject getAllStrikesJson(Guild guild) + { + JSONObject obj = new JSONObject(); + getAllStrikes(guild).entrySet().forEach(e -> obj.put(Long.toString(e.getKey()), e.getValue())); + return obj; + } } diff --git a/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java b/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java index 06ad346..d0ad637 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java @@ -20,11 +20,15 @@ import com.jagrosh.easysql.SQLColumn; import com.jagrosh.easysql.columns.InstantColumn; import com.jagrosh.easysql.columns.LongColumn; +import com.jagrosh.vortex.utils.Pair; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; +import org.json.JSONObject; /** * @@ -47,6 +51,20 @@ return GUILD_ID+", "+USER_ID; } + public JSONObject getAllBansJson(Guild guild) + { + List> list = read(selectAll(GUILD_ID.is(guild.getId())), rs -> + { + List> arr = new ArrayList<>(); + while(rs.next()) + arr.add(new Pair<>(USER_ID.getValue(rs), FINISH.getValue(rs))); + return arr; + }); + JSONObject json = new JSONObject(); + list.forEach(p -> json.put(Long.toString(p.getKey()), p.getValue().getEpochSecond())); + return json; + } + public void setBan(Guild guild, long userId, Instant finish) { readWrite(selectAll(GUILD_ID.is(guild.getId())+" AND "+USER_ID.is(userId)), rs -> diff --git a/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java b/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java index 16b7f6b..73d527c 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java @@ -20,13 +20,17 @@ import com.jagrosh.easysql.SQLColumn; import com.jagrosh.easysql.columns.InstantColumn; import com.jagrosh.easysql.columns.LongColumn; +import com.jagrosh.vortex.utils.Pair; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Role; +import org.json.JSONObject; /** * @@ -49,6 +53,20 @@ return GUILD_ID+", "+USER_ID; } + public JSONObject getAllMutesJson(Guild guild) + { + List> list = read(selectAll(GUILD_ID.is(guild.getId())), rs -> + { + List> arr = new ArrayList<>(); + while(rs.next()) + arr.add(new Pair<>(USER_ID.getValue(rs), FINISH.getValue(rs))); + return arr; + }); + JSONObject json = new JSONObject(); + list.forEach(p -> json.put(Long.toString(p.getKey()), p.getValue().getEpochSecond())); + return json; + } + public boolean isMuted(Member member) { return read(selectAll(GUILD_ID.is(member.getGuild().getId())+" AND "+USER_ID.is(member.getUser().getId())+" AND "+FINISH.isGreaterThan(Instant.now().getEpochSecond())), diff --git a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java index ab69863..781ac5a 100644 --- a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java +++ b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java @@ -77,7 +77,7 @@ } if(!toUpdate.isEmpty()) { - LOG.info("DEBUG Modlog updating " + toUpdate.size() + " guilds: " + toUpdate.toString()); + LOG.debug("DEBUG Modlog updating " + toUpdate.size() + " guilds: " + toUpdate.toString()); try { long time, diff; diff --git a/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java b/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java index f07b34d..242a19e 100644 --- a/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java @@ -87,7 +87,7 @@ args = args.substring(mat.group().length()).trim(); if(found) continue; - unresolved.add(mat.group()); + unresolved.add(FormatUtil.filterEveryone(mat.group())); found = true; continue; } diff --git a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java index 91c4565..3d2ffcf 100644 --- a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java @@ -48,7 +48,8 @@ return input.replace("\u202E","") // RTL override .replace("@everyone","@\u0435veryone") // cyrillic e .replace("@here","@h\u0435re") // cyrillic e - .replace("discord.gg/", "dis\u0441ord.gg/"); // cyrillic c + .replace("discord.gg/", "discord\u2024gg/") // one dot leader + .replace("@&", "\u0DB8&"); // role failsafe } public static String formatMessage(Message m) diff --git a/src/main/java/com/jagrosh/vortex/utils/Pair.java b/src/main/java/com/jagrosh/vortex/utils/Pair.java new file mode 100644 index 0000000..22c1776 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/utils/Pair.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 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.utils; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class Pair +{ + private final K key; + private final V value; + + public Pair(K key, V value) + { + this.key = key; + this.value = value; + } + + public K getKey() + { + return key; + } + + public V getValue() + { + return value; + } +}