diff --git a/lists/referral_domains.txt b/lists/referral_domains.txt index 5514b42..5d82af9 100644 --- a/lists/referral_domains.txt +++ b/lists/referral_domains.txt @@ -3,8 +3,13 @@ // IP Loggers iplogger.com +iplogger.org +iplogger.ru blasze.tk ps3cfw.com +2no.co +yip.su +gotyouripboi.com // Grabify (IP Loggers) grabify.link @@ -24,6 +29,11 @@ bucks.as discörd.com minecräft.com +discördapp.com +freegiftcards.co +disçordapp.com +särahah.eu +särahah.pl shört.co cyberh1.xyz @@ -50,6 +60,7 @@ pointsprizes.com weeklyjob.online justdoit.cards +free.gg // Scams oprewards.com diff --git a/pom.xml b/pom.xml index 39cfd21..3d70f53 100644 --- a/pom.xml +++ b/pom.xml @@ -24,12 +24,12 @@ net.dv8tion JDA - 3.7.0_384 + 3.7.1_395 com.jagrosh jda-utilities - 2.1.1 + 2.1.4 pom diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index 534c918..d3b9ba3 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -47,6 +47,7 @@ import net.dv8tion.jda.bot.sharding.ShardManager; import net.dv8tion.jda.core.entities.ChannelType; import net.dv8tion.jda.core.exceptions.PermissionException; +import net.dv8tion.jda.core.utils.SessionControllerAdapter; import net.dv8tion.jda.webhook.WebhookClient; import net.dv8tion.jda.webhook.WebhookClientBuilder; @@ -84,7 +85,7 @@ * 9 - number of shards */ List tokens = Files.readAllLines(Paths.get("config.txt")); - waiter = new EventWaiter(); + waiter = new EventWaiter(Executors.newSingleThreadScheduledExecutor(), false); threadpool = Executors.newScheduledThreadPool(40); database = new Database(tokens.get(4), tokens.get(5), tokens.get(6)); uploader = new TextUploader(this, Long.parseLong(tokens.get(8))); @@ -103,6 +104,8 @@ .setLinkedCacheSize(0) .setGuildSettingsManager(database.settings) .setListener(new CommandExceptionListener()) + .setScheduleExecutor(threadpool) + .setShutdownAutomatically(false) .addCommands(// General new AboutCommand(Color.CYAN, "and I'm here to keep your Discord server safe and make moderating easy!", new String[]{"Moderation commands","Configurable automoderation","Very easy setup"},Constants.PERMISSIONS), @@ -188,6 +191,22 @@ .setGame(Game.playing("loading...")) .setBulkDeleteSplittingEnabled(false) .setRequestTimeoutRetry(true) + .setSessionController(new SessionControllerAdapter() + { + @Override + protected void runWorker() + { + synchronized (lock) + { + if (workerHandle == null) + { + workerHandle = new SessionControllerAdapter.QueueWorker(15); + System.gc(); + workerHandle.start(); + } + } + } + }) .build(); modlog.start(); diff --git a/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java b/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java index 1dc23cb..ac12a9b 100644 --- a/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java +++ b/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java @@ -69,7 +69,7 @@ public void applyStrikes(Member moderator, OffsetDateTime nowo, User target, int number, String reason) { - boolean shouldDM = moderator.getGuild().getMemberById(target.getIdLong())!=null; + boolean isMember = moderator.getGuild().getMemberById(target.getIdLong())!=null; Instant now = nowo.toInstant(); int[] counts = vortex.getDatabase().strikes.addStrikes(moderator.getGuild(), target.getIdLong(), number); if(counts[0]>110 && counts[1]>110) @@ -79,7 +79,7 @@ if(punishments.isEmpty()) { vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], target, reason); - OtherUtil.safeDM(target, dmmsg, shouldDM, ()->{}); + OtherUtil.safeDM(target, dmmsg, isMember, ()->{}); } else { @@ -87,7 +87,7 @@ boolean canBan = moderator.getGuild().getSelfMember().hasPermission(Permission.BAN_MEMBERS); if(punishments.stream().anyMatch(p -> p.action==Action.BAN) && canBan) { - OtherUtil.safeDM(target, dmmsg + punish(Action.BAN, moderator.getGuild()), shouldDM, + OtherUtil.safeDM(target, dmmsg + punish(Action.BAN, moderator.getGuild()), isMember, () -> moderator.getGuild().getController().ban(target, 7, notimeaudit).queue()); vortex.getDatabase().tempbans.clearBan(moderator.getGuild(), target.getIdLong()); return; @@ -106,7 +106,7 @@ if(banDuration>0 && canBan) { int finalBanDuration = banDuration; - OtherUtil.safeDM(target, dmmsg + punishTime(Action.TEMPBAN, moderator.getGuild(), banDuration), shouldDM, + OtherUtil.safeDM(target, dmmsg + punishTime(Action.TEMPBAN, moderator.getGuild(), banDuration), isMember, () -> moderator.getGuild().getController().ban(target, 7, LogUtil.auditStrikeReasonFormat(moderator, finalBanDuration, counts[0], counts[1], reason)).queue()); vortex.getDatabase().tempbans.setBan(moderator.getGuild(), target.getIdLong(), now.plus(banDuration, ChronoUnit.MINUTES)); if(muteDuration>0) @@ -115,7 +115,7 @@ } if(punishments.stream().anyMatch(p -> p.action==Action.SOFTBAN) && canBan) { - OtherUtil.safeDM(target, dmmsg + punish(Action.SOFTBAN, moderator.getGuild()), shouldDM, + OtherUtil.safeDM(target, dmmsg + punish(Action.SOFTBAN, moderator.getGuild()), isMember, () -> moderator.getGuild().getController().ban(target, 7, notimeaudit).queue( s -> moderator.getGuild().getController().unban(target).reason(notimeaudit).queueAfter(4, TimeUnit.SECONDS))); if(muteDuration>0) @@ -127,7 +127,7 @@ { if(moderator.getGuild().isMember(target)) { - OtherUtil.safeDM(target, dmmsg + punish(Action.KICK, moderator.getGuild()), shouldDM, + OtherUtil.safeDM(target, dmmsg + punish(Action.KICK, moderator.getGuild()), isMember, () -> moderator.getGuild().getController().kick(target.getId(), notimeaudit).queue()); } else @@ -147,7 +147,7 @@ if(muted==null || mem==null || !moderator.getGuild().getSelfMember().canInteract(muted)) { vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], target, reason); - OtherUtil.safeDM(target, dmmsg, shouldDM, ()->{}); + OtherUtil.safeDM(target, dmmsg, isMember, ()->{}); return; } if(mem.getRoles().contains(muted)) @@ -163,7 +163,7 @@ .queue(); } OtherUtil.safeDM(target, dmmsg + (muteDuration==Integer.MAX_VALUE ? punish(Action.MUTE, moderator.getGuild()) - : punishTime(Action.TEMPMUTE, moderator.getGuild(), muteDuration)), shouldDM, ()->{}); + : punishTime(Action.TEMPMUTE, moderator.getGuild(), muteDuration)), isMember, ()->{}); } } } diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AutoraidmodeCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AutoraidmodeCmd.java index 0251f2c..945393f 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AutoraidmodeCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AutoraidmodeCmd.java @@ -62,7 +62,7 @@ { event.replyError("Valid options are `OFF`, `ON`, or `/`" + "\nSetting to `OFF` means the bot will never automatically enable raid mode" - + "\nSetting to `ON` will use the recommended value of 10 joins per 10 seconds to rigger Anti-Raid mode" + + "\nSetting to `ON` will use the recommended value of 10 joins per 10 seconds to trigger Anti-Raid mode" + "\nSetting a customizable threshhold is possible; ex: `10/20` for 10 joins in 20 seconds" + "\nFor more information, check out the wiki: <"+Constants.Wiki.RAID_MODE+">"); return; diff --git a/src/main/java/com/jagrosh/vortex/commands/general/ServerinfoCmd.java b/src/main/java/com/jagrosh/vortex/commands/general/ServerinfoCmd.java index d4bd877..15f3690 100644 --- a/src/main/java/com/jagrosh/vortex/commands/general/ServerinfoCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/general/ServerinfoCmd.java @@ -31,7 +31,8 @@ */ public class ServerinfoCmd extends Command { - private final String linestart = "\u25AB"; + private final static String LINESTART = "\u25AB"; + public ServerinfoCmd() { this.name = "serverinfo"; @@ -42,7 +43,8 @@ } @Override - protected void execute(CommandEvent event) { + protected void execute(CommandEvent event) + { Guild guild = event.getGuild(); long onlineCount = guild.getMembers().stream().filter((u) -> (u.getOnlineStatus()!=OnlineStatus.OFFLINE)).count(); long botCount = guild.getMembers().stream().filter(m -> m.getUser().isBot()).count(); @@ -54,17 +56,19 @@ case HIGH: verif = "(╯°□°)╯︵ ┻━┻"; break; default: verif = guild.getVerificationLevel().name(); break; } - String str = linestart+"ID: **"+guild.getId()+"**\n" - +linestart+"Owner: "+FormatUtil.formatUser(guild.getOwner().getUser())+"\n" - +linestart+"Location: "+guild.getRegion().getEmoji()+" **"+guild.getRegion().getName()+"**\n" - +linestart+"Creation: **"+guild.getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n" - +linestart+"Users: **"+guild.getMembers().size()+"** ("+onlineCount+" online, "+botCount+" bots)\n" - +linestart+"Channels: **"+guild.getTextChannels().size()+"** Text, **"+guild.getVoiceChannels().size()+"** Voice\n" - +linestart+"Verification: **"+verif+"**"; + String str = LINESTART+"ID: **"+guild.getId()+"**\n" + +LINESTART+"Owner: "+FormatUtil.formatUser(guild.getOwner().getUser())+"\n" + +LINESTART+"Location: "+(guild.getRegion().getEmoji()==null ? "\u2754" : guild.getRegion().getEmoji())+" **"+guild.getRegion().getName()+"**\n" + +LINESTART+"Creation: **"+guild.getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n" + +LINESTART+"Users: **"+guild.getMemberCache().size()+"** ("+onlineCount+" online, "+botCount+" bots)\n" + +LINESTART+"Channels: **"+guild.getTextChannelCache().size()+"** Text, **"+guild.getVoiceChannelCache().size()+"** Voice, **"+guild.getCategoryCache().size()+"** Categories\n" + +LINESTART+"Verification: **"+verif+"**"; + if(!guild.getFeatures().isEmpty()) + str += "\n"+LINESTART+"Features: **"+String.join("**, **", guild.getFeatures())+"**"; if(guild.getSplashId()!=null) { builder.setImage(guild.getSplashUrl()+"?size=1024"); - str += "\n<:partner:314068430556758017> **Discord Partner** <:partner:314068430556758017>"; + str += "\n"+LINESTART+"Splash: "; } if(guild.getIconUrl()!=null) builder.setThumbnail(guild.getIconUrl()); @@ -72,5 +76,4 @@ builder.setDescription(str); event.reply(new MessageBuilder().append(title).setEmbed(builder.build()).build()); } - } 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 20514da..f2e4b53 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java @@ -26,6 +26,8 @@ import com.jagrosh.vortex.utils.LogUtil; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; import net.dv8tion.jda.core.entities.Role; /** @@ -66,6 +68,7 @@ String reason = LogUtil.auditReasonFormat(event.getMember(), minutes, args.reason); Role modrole = vortex.getDatabase().settings.getSettings(event.getGuild()).getModeratorRole(event.getGuild()); StringBuilder builder = new StringBuilder(); + List ids = new ArrayList<>(args.ids); args.members.forEach(m -> { @@ -76,29 +79,29 @@ else if(modrole!=null && m.getRoles().contains(modrole)) builder.append("\n").append(event.getClient().getError()).append(" I won't ban ").append(FormatUtil.formatUser(m.getUser())).append(" because they have the Moderator Role"); else - args.ids.add(m.getUser().getIdLong()); + ids.add(m.getUser().getIdLong()); }); args.unresolved.forEach(un -> builder.append("\n").append(event.getClient().getWarning()).append(" Could not resolve `").append(un).append("` to a user ID")); - args.users.forEach(u -> args.ids.add(u.getIdLong())); + args.users.forEach(u -> ids.add(u.getIdLong())); - if(args.ids.isEmpty()) + if(ids.isEmpty()) { event.reply(builder.toString()); return; } - if(args.ids.size() > 5) + if(ids.size() > 5) event.reactSuccess(); Instant unbanTime = Instant.now().plus(minutes, ChronoUnit.MINUTES); String time = minutes==0 ? "" : " for "+FormatUtil.secondsToTimeCompact(minutes*60); - for(int i=0; i { builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully banned <@").append(id).append(">").append(time); diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/StrikeCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/StrikeCmd.java index e89d52b..bb25ad7 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/StrikeCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/StrikeCmd.java @@ -23,6 +23,7 @@ import com.jagrosh.vortex.utils.FormatUtil; import java.util.LinkedList; import java.util.List; +import java.util.Set; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.User; @@ -127,7 +128,7 @@ }); } - private void strikeAll(List users, int numstrikes, String reason, StringBuilder builder, CommandEvent event) + private void strikeAll(Set users, int numstrikes, String reason, StringBuilder builder, CommandEvent event) { users.forEach(u -> { diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java index 835c1d0..e7dc8f2 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java @@ -89,7 +89,7 @@ for(int i=0; i { builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully unbanned ").append(FormatUtil.formatUser(ban.getUser())); diff --git a/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java b/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java index 63a6cc4..f8bffe1 100644 --- a/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java @@ -15,8 +15,10 @@ */ package com.jagrosh.vortex.utils; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.dv8tion.jda.core.entities.Guild; @@ -41,10 +43,10 @@ public static ResolvedArgs resolve(String args, boolean allowTime, Guild guild) { - List members = new LinkedList<>(); - List users = new LinkedList<>(); - List ids = new LinkedList<>(); - List unresolved = new LinkedList<>(); + Set members = new LinkedHashSet<>(); + Set users = new LinkedHashSet<>(); + Set ids = new LinkedHashSet<>(); + Set unresolved = new LinkedHashSet<>(); Matcher mat; User u; long i; @@ -125,14 +127,14 @@ public static class ResolvedArgs { - public final List members; - public final List users; - public final List ids; - public final List unresolved; + public final Set members; + public final Set users; + public final Set ids; + public final Set unresolved; public final int time; public final String reason; - private ResolvedArgs(List members, List users, List ids, List unresolved, int time, String reason) + private ResolvedArgs(Set members, Set users, Set ids, Set unresolved, int time, String reason) { this.members = members; this.users = users;