diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a4b3f4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/live/
+/target/
+/avatars/
+/backups/
+/database/
+nb*.xml
\ No newline at end of file
diff --git a/lists/copypastas.txt b/lists/copypastas.txt
index ebdc144..396f7d4 100644
--- a/lists/copypastas.txt
+++ b/lists/copypastas.txt
@@ -19,6 +19,6 @@
Lennipede || ╚═(███)═╝ && Lenn
// Text
-Navy Seals || say about me && I’ll have you know I && I am trained && Think again && Not only am I extensively trained && kiddo
+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
\ No newline at end of file
diff --git a/lists/referral_domains.txt b/lists/referral_domains.txt
index dc2372e..2ed804a 100644
--- a/lists/referral_domains.txt
+++ b/lists/referral_domains.txt
@@ -1,4 +1,4 @@
-// Referral Domain List
+// Referral Domain List
// This list contains referral sites
// IP Loggers
@@ -81,12 +81,14 @@
// Referral Sites
black-friday.ga
+boost.ink
easycommerce.cf
featu.re
free.gg
justdoit.cards
makeprogress.ga
pointsprizes.com
+selly.gg
weeklyjob.online
wn.nr
@@ -99,7 +101,9 @@
outbuck.com
// Scams
+amazingsexdating.com
easter-event.com
+fortnite-christmas.com
fortnite-gifts.com
fortnite-giveaway.com
fortnite-special.com
@@ -113,6 +117,8 @@
myetherermwallet.com
oprewards.com
rbxfree.com
+roblox-christmas.com
+steam-event.com
steam-gift-codes.com
steam-money.org
steam-wallet-rewards.com
@@ -121,4 +127,4 @@
steamreward.com
steamspecial.com
steamsummer.com
-
+whatsappx.com
diff --git a/pom.xml b/pom.xml
index 38c01ef..fe17719 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.jagrosh
Vortex
- 2.1
+ 2.2
jar
@@ -18,18 +18,23 @@
jcenter-bintray
http://jcenter.bintray.com
+
+ sonatype
+ sonatype-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots/
+
net.dv8tion
JDA
- 3.8.0_425
+ 3.8.2_459
com.jagrosh
jda-utilities
- 2.1.4
+ 2.1.5
pom
@@ -42,6 +47,11 @@
logback-classic
1.2.3
+
+ com.jagrosh
+ Vortex-Pro
+ 0.1
+
diff --git a/src/main/java/com/jagrosh/vortex/Constants.java b/src/main/java/com/jagrosh/vortex/Constants.java
index b87d314..dc3fcad 100644
--- a/src/main/java/com/jagrosh/vortex/Constants.java
+++ b/src/main/java/com/jagrosh/vortex/Constants.java
@@ -32,13 +32,14 @@
public final static String LOADING = "";
public final static String HELP_REACTION = SUCCESS.replaceAll("", "$1:$2");
public final static String ERROR_REACTION = ERROR.replaceAll("", "$1:$2");
+ public final static String VORTEX_EMOJI = "<:Vortex:386971287282515970>";
public final static Permission[] PERMISSIONS = {Permission.ADMINISTRATOR, Permission.BAN_MEMBERS, Permission.KICK_MEMBERS, Permission.MANAGE_ROLES,
Permission.MANAGE_SERVER, Permission.MESSAGE_ADD_REACTION, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_READ,
Permission.MESSAGE_WRITE,Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_HISTORY, Permission.MESSAGE_EXT_EMOJI,
Permission.MESSAGE_MANAGE, Permission.VOICE_CONNECT, Permission.VOICE_MOVE_OTHERS, Permission.VOICE_DEAF_OTHERS,
Permission.VOICE_MUTE_OTHERS, Permission.NICKNAME_CHANGE, Permission.NICKNAME_MANAGE, Permission.VIEW_AUDIT_LOGS};
public final static String SERVER_INVITE = "https://discord.gg/0p9LSGoRLu6Pet0k";
- public final static String BOT_INVITE = "https://discordapp.com/oauth2/authorize?client_id=240254129333731328&scope=bot&permissions="+Permission.getRaw(PERMISSIONS);
+ //public final static String BOT_INVITE = "https://discordapp.com/oauth2/authorize?client_id=240254129333731328&scope=bot&permissions="+Permission.getRaw(PERMISSIONS);
// public final static String BOT_INVITE = "https://discordapp.com/oauth2/authorize?client_id=169463754382114816&scope=bot&permissions="+Permission.getRaw(PERMISSIONS);
public final static String OWNER_ID = "113156185389092864";
public final static String DONATION_LINK = "https://patreon.com/jagrosh";
@@ -46,9 +47,11 @@
public final static class Wiki
{
+ public final static String SHORT_WIKI = "https://git.io/fxHam";
public final static String SHORT_COMMANDS = "https://git.io/vAr0G";
public final static String WIKI_BASE = "https://github.com/jagrosh/Vortex/wiki";
+ public final static String START = WIKI_BASE + "/Getting-Started";
public final static String LOG_TIMEZONE = WIKI_BASE + "/Log-Timezone";
public final static String RAID_MODE = WIKI_BASE + "/Raid-Mode";
public final static String COMMANDS = WIKI_BASE + "/Commands";
diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java
index 695e219..2cf574c 100644
--- a/src/main/java/com/jagrosh/vortex/Vortex.java
+++ b/src/main/java/com/jagrosh/vortex/Vortex.java
@@ -22,7 +22,6 @@
import com.jagrosh.vortex.commands.tools.*;
import com.jagrosh.vortex.commands.owner.*;
import com.jagrosh.vortex.commands.settings.*;
-import java.awt.Color;
import java.nio.file.*;
import java.util.List;
import java.util.concurrent.Executors;
@@ -41,6 +40,7 @@
import com.jagrosh.vortex.logging.MessageCache;
import com.jagrosh.vortex.logging.ModLogger;
import com.jagrosh.vortex.logging.TextUploader;
+import com.jagrosh.vortex.utils.BlockingSessionController;
import com.jagrosh.vortex.utils.FormatUtil;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;
@@ -48,7 +48,6 @@
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.core.utils.cache.CacheFlag;
import net.dv8tion.jda.webhook.WebhookClient;
import net.dv8tion.jda.webhook.WebhookClientBuilder;
@@ -85,6 +84,8 @@
* 7 - log webhook url
* 8 - guild id : category id
* 9 - number of shards
+ * 10 - url resolver url
+ * 11 - url resolver secret
*/
List tokens = Files.readAllLines(Paths.get("config.txt"));
waiter = new EventWaiter(Executors.newSingleThreadScheduledExecutor(), false);
@@ -96,11 +97,12 @@
basiclog = new BasicLogger(this);
messages = new MessageCache();
logwebhook = new WebhookClientBuilder(tokens.get(7)).build();
- automod = new AutoMod(this);
+ automod = new AutoMod(this, tokens);
strikehandler = new StrikeHandler(this);
CommandClient client = new CommandClientBuilder()
.setPrefix(Constants.PREFIX)
- .setGame(Game.watching("Type "+Constants.PREFIX+"help"))
+ //.setGame(Game.watching("Type "+Constants.PREFIX+"help"))
+ .setGame(Game.playing(Constants.Wiki.SHORT_WIKI))
.setOwnerId(Constants.OWNER_ID)
.setServerInvite(Constants.SERVER_INVITE)
.setEmojis(Constants.SUCCESS, Constants.WARNING, Constants.ERROR)
@@ -110,8 +112,9 @@
.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),
+ //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),
+ new AboutCmd(),
new InviteCmd(),
new PingCommand(),
new RoleinfoCmd(),
@@ -194,23 +197,8 @@
.setGame(Game.playing("loading..."))
.setBulkDeleteSplittingEnabled(false)
.setRequestTimeoutRetry(true)
- .setDisabledCacheFlags(EnumSet.of(CacheFlag.EMOTE))
- .setSessionController(new SessionControllerAdapter()
- {
- @Override
- protected void runWorker()
- {
- synchronized (lock)
- {
- if (workerHandle == null)
- {
- workerHandle = new SessionControllerAdapter.QueueWorker(20);
- System.gc();
- workerHandle.start();
- }
- }
- }
- })
+ .setDisabledCacheFlags(EnumSet.of(CacheFlag.EMOTE, CacheFlag.GAME)) //TODO: dont disable GAME
+ .setSessionController(new BlockingSessionController())
.build();
modlog.start();
@@ -290,8 +278,8 @@
{
if(!g.isAvailable())
return false;
- int botcount = (int)g.getMembers().stream().filter(m -> m.getUser().isBot()).count();
- if(g.getMembers().size()-botcount<10 || (botcount>20 && ((double)botcount/g.getMembers().size())>0.65))
+ 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.65))
{
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 bea690b..515dd8a 100644
--- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
+++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
@@ -20,6 +20,7 @@
import com.jagrosh.vortex.database.managers.AutomodManager;
import com.jagrosh.vortex.database.managers.AutomodManager.AutomodSettings;
import com.jagrosh.vortex.logging.MessageCache.CachedMessage;
+import com.jagrosh.vortex.pro.URLResolver;
import com.jagrosh.vortex.utils.FixedCache;
import com.jagrosh.vortex.utils.OtherUtil;
import java.time.OffsetDateTime;
@@ -51,7 +52,7 @@
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 BASE_URL = Pattern.compile("https?:\\/\\/(?:[^?&:\\/\\s]+\\.)?([^?&:\\/\\s]+\\.\\w+)(?:\\W|$)", Pattern.CASE_INSENSITIVE);
private static final Pattern LINK = Pattern.compile("https?:\\/\\/\\S+", Pattern.CASE_INSENSITIVE);
private static final String INVITE_LINK = "https?:\\/\\/discord(?:app\\.com\\/invite|\\.gg)\\/(\\S+)";
@@ -63,15 +64,16 @@
private final Vortex vortex;
private String[] refLinkList;
- private final URLResolver urlResolver = new URLResolver();
+ private final URLResolver urlResolver;
private final InviteResolver inviteResolver = new InviteResolver();
private final CopypastaResolver copypastaResolver = new CopypastaResolver();
private final FixedCache spams = new FixedCache<>(3000);
private final HashMap latestGuildJoin = new HashMap<>();
- public AutoMod(Vortex vortex)
+ public AutoMod(Vortex vortex, List config)
{
this.vortex = vortex;
+ urlResolver = new URLResolver(config.get(10), config.get(11));
loadCopypastas();
loadReferralDomains();
}
@@ -520,7 +522,7 @@
private boolean isReferralUrl(String url)
{
for(String reflink: refLinkList)
- if(reflink.equals(url))
+ if(reflink.equalsIgnoreCase(url))
return true;
return false;
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/general/AboutCmd.java b/src/main/java/com/jagrosh/vortex/commands/general/AboutCmd.java
new file mode 100644
index 0000000..0e8f2a4
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/general/AboutCmd.java
@@ -0,0 +1,64 @@
+/*
+ * 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.general;
+
+import com.jagrosh.jdautilities.command.Command;
+import com.jagrosh.jdautilities.command.CommandEvent;
+import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo;
+import com.jagrosh.vortex.Constants;
+import com.jagrosh.vortex.utils.FormatUtil;
+import java.awt.Color;
+import net.dv8tion.jda.bot.sharding.ShardManager;
+import net.dv8tion.jda.core.EmbedBuilder;
+import net.dv8tion.jda.core.JDAInfo;
+import net.dv8tion.jda.core.MessageBuilder;
+import net.dv8tion.jda.core.Permission;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public class AboutCmd extends Command
+{
+ public AboutCmd()
+ {
+ this.name = "about";
+ this.help = "shows info about the bot";
+ this.guildOnly = false;
+ this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS};
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ ShardManager sm = event.getJDA().asBot().getShardManager();
+ event.reply(new MessageBuilder()
+ .setContent(Constants.VORTEX_EMOJI + " **All about Vortex** " + Constants.VORTEX_EMOJI)
+ .setEmbed(new EmbedBuilder()
+ .setColor(event.getGuild()==null ? Color.GRAY : event.getSelfMember().getColor())
+ .setDescription("Hello, I am **Vortex**#8540, a bot designed to keep your server safe and make moderating fast and easy!\n"
+ + "I was written in Java by **jagrosh**#4824 using [JDA](" + JDAInfo.GITHUB + ") and [JDA-Utilities](" + JDAUtilitiesInfo.GITHUB + ")\n"
+ + "Type `" + event.getClient().getPrefix() + event.getClient().getHelpWord() + "` for help and information.\n\n"
+ + FormatUtil.helpLinks(event))
+ .addField("Stats", sm.getShardsTotal()+ " Shards\n" + sm.getGuildCache().size() + " Servers", true)
+ .addField("", sm.getUserCache().size() + " Users\n" + Math.round(sm.getAveragePing()) + "ms Avg Ping", true)
+ .addField("", sm.getTextChannelCache().size() + " Text Channels\n" + sm.getVoiceChannelCache().size() + " Voice Channels", true)
+ .setFooter("Last restart", null)
+ .setTimestamp(event.getClient().getStartTime())
+ .build())
+ .build());
+ }
+}
diff --git a/src/main/java/com/jagrosh/vortex/commands/general/InviteCmd.java b/src/main/java/com/jagrosh/vortex/commands/general/InviteCmd.java
index 4a3e074..7ec5915 100644
--- a/src/main/java/com/jagrosh/vortex/commands/general/InviteCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/general/InviteCmd.java
@@ -23,8 +23,8 @@
*
* @author John Grosh (jagrosh)
*/
-public class InviteCmd extends Command {
-
+public class InviteCmd extends Command
+{
public InviteCmd()
{
this.name = "invite";
@@ -33,11 +33,11 @@
}
@Override
- protected void execute(CommandEvent event) {
+ protected void execute(CommandEvent event)
+ {
event.reply("Hello. I am **"+event.getJDA().getSelfUser().getName()+"**, a simple moderation bot built by **jagrosh**#4824."
+ "\nYou can find out how to add me to your server with the link below:"
- + "\n\n\uD83D\uDD17 **<"+Constants.Wiki.WIKI_BASE+">**"
+ + "\n\n\uD83D\uDD17 **<"+Constants.Wiki.START+">**"
+ "\n\nFor assistance, check out the wiki: <"+Constants.Wiki.WIKI_BASE+">");
}
-
}
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 dd95dac..f2fb250 100644
--- a/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java
@@ -157,7 +157,6 @@
default:
str="Playing";
break;
-
}
return str+" *"+game.getName()+"*";
}
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 7ad9b60..5616fcc 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/CheckCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/CheckCmd.java
@@ -18,12 +18,12 @@
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.commons.utils.FinderUtil;
import com.jagrosh.vortex.Action;
-import com.jagrosh.vortex.Constants;
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.commands.ModCommand;
import com.jagrosh.vortex.utils.FormatUtil;
import java.util.List;
import net.dv8tion.jda.core.Permission;
+import net.dv8tion.jda.core.entities.Guild.Ban;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Role;
import net.dv8tion.jda.core.entities.User;
@@ -41,6 +41,7 @@
this.arguments = "";
this.help = "checks a user";
this.guildOnly = true;
+ this.botPermissions = new Permission[]{Permission.BAN_MEMBERS};
}
@Override
@@ -51,6 +52,7 @@
event.replySuccess("This command is used to see a user's strikes and mute/ban status for the current server. Please include a user or user ID to check.");
return;
}
+ event.getChannel().sendTyping().queue();
List members = FinderUtil.findMembers(event.getArgs(), event.getGuild());
if(!members.isEmpty())
{
@@ -82,21 +84,26 @@
private void check(CommandEvent event, User user)
{
+ if(event.getGuild().isMember(user))
+ check(event, user, null);
+ else
+ event.getGuild().getBan(user).queue(ban -> check(event, user, ban), t -> check(event, user, null));
+ }
+
+ private void check(CommandEvent event, User user, Ban ban)
+ {
int strikes = vortex.getDatabase().strikes.getStrikes(event.getGuild(), user.getIdLong());
int minutesMuted = vortex.getDatabase().tempmutes.timeUntilUnmute(event.getGuild(), user.getIdLong());
Role mRole = vortex.getDatabase().settings.getSettings(event.getGuild()).getMutedRole(event.getGuild());
- boolean actuallyMuted = mRole!=null && event.getGuild().isMember(user) && event.getGuild().getMember(user).getRoles().contains(mRole);
int minutesBanned = vortex.getDatabase().tempbans.timeUntilUnban(event.getGuild(), user.getIdLong());
String str = "Moderation Information for "+FormatUtil.formatFullUser(user)+":\n"
- + Action.STRIKE.getEmoji() + " Strikes: **"+strikes+"**\n";
- if(minutesMuted<=0)
- str += actuallyMuted ? Action.MUTE.getEmoji() + " Muted: **Manually**" : Action.UNMUTE.getEmoji() + " Not Muted";
- else
- str += (minutesMuted==Integer.MAX_VALUE
- ? Action.MUTE.getEmoji() + " Muted: **Forever**"
- : Action.TEMPMUTE.getEmoji() + " Muted: " + FormatUtil.secondsToTime(minutesMuted*60))
- + (actuallyMuted ? "" : " " + Constants.WARNING + " No 'Muted' role!");
- str += minutesBanned<=0 ? "" : "\n" + Action.TEMPBAN.getEmoji() + " Banned: " + FormatUtil.secondsToTime(minutesBanned*60);
+ + Action.STRIKE.getEmoji() + " Strikes: **"+strikes+"**\n"
+ + Action.MUTE.getEmoji() + " Muted: **" + (event.getGuild().isMember(user)
+ ? (event.getGuild().getMember(user).getRoles().contains(mRole) ? "Yes" : "No")
+ : "Not In Server") + "**\n"
+ + 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);
}
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/CleanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/CleanCmd.java
index 2976e3c..50ff089 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/CleanCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/CleanCmd.java
@@ -47,7 +47,7 @@
private final Pattern ID_PATTERN = Pattern.compile("\\b(\\d{17,22})\\b");
private final Pattern NUM_PATTERN = Pattern.compile("\\b(\\d{1,4})\\b");
private final String week2limit = " Note: Messages older than 2 weeks cannot be cleaned.";
- private final String noparams = "**No valid cleaning paramaters included!**\n"
+ private final String noparams = "**No valid cleaning parameters included!**\n"
+"This command is to remove many messages quickly. Pinned messages are ignored. "
+ "Messages can be filtered with various parameters. Mutliple arguments can be used, and "
+ "the order of parameters does not matter. The following parameters are supported:\n"
diff --git a/src/main/java/com/jagrosh/vortex/database/managers/AuditCacheManager.java b/src/main/java/com/jagrosh/vortex/database/managers/AuditCacheManager.java
index d2748a6..6d41db1 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/AuditCacheManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/AuditCacheManager.java
@@ -68,13 +68,15 @@
filtered.add(0, entry);
OLD.updateValue(rs, list.get(0).getIdLong());
- if(list.size()>1)
+ if(list.size()>=3)
{
OLDER.updateValue(rs, list.get(1).getIdLong());
- if(list.size()>2)
- OLDEST.updateValue(rs, list.get(2).getIdLong());
- else
- OLDEST.updateValue(rs, list.get(1).getIdLong());
+ OLDEST.updateValue(rs, list.get(2).getIdLong());
+ }
+ else if(list.size()==2)
+ {
+ OLDER.updateValue(rs, list.get(1).getIdLong());
+ OLDEST.updateValue(rs, list.get(1).getIdLong());
}
else
{
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 89cc603..4b47543 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java
@@ -33,7 +33,7 @@
public class AutomodManager extends DataManager
{
public final static int MAX_STRIKES = 100;
- public final static int MENTION_MINIMUM = 7;
+ public final static int MENTION_MINIMUM = 4;
public final static int ROLE_MENTION_MINIMUM = 2;
private static final String SETTINGS_TITLE = "\uD83D\uDEE1 Automod Settings";
@@ -94,13 +94,13 @@
: "Disabled\n\n")
+ "__Maximum Mentions__\n" + (settings.maxMentions==0 && settings.maxRoleMentions==0
? "Disabled\n\n"
- : "Max User Mentions: " + (settings.maxMentions==0 ? "None\n" : "`" + settings.maxMentions + "`\n") +
- "Max Role Mentions: " + (settings.maxRoleMentions==0 ? "None\n\n" : "`" + settings.maxRoleMentions + "`\n\n"))
- + "__Spam Prevention__\n" + (settings.maxLines==0 && settings.copypastaStrikes==0 && settings.everyoneStrikes==0
+ : "User Mentions: " + (settings.maxMentions==0 ? "None\n" : "`" + settings.maxMentions + "`\n") +
+ "Role Mentions: " + (settings.maxRoleMentions==0 ? "None\n\n" : "`" + settings.maxRoleMentions + "`\n\n"))
+ + "__Misc Msg Settings__\n" + (settings.maxLines==0 && settings.copypastaStrikes==0 && settings.everyoneStrikes==0
? "Disabled\n\n"
- : "Max Lines / Message: "+(settings.maxLines==0 ? "Disabled\n" : "`"+settings.maxLines+"`\n") +
+ : "Max Lines / Msg: "+(settings.maxLines==0 ? "Disabled\n" : "`"+settings.maxLines+"`\n") +
"Copypasta: `" + settings.copypastaStrikes + " " + Action.STRIKE.getEmoji() + "`\n" +
- "@\u0435veryone Attempt: `" + settings.everyoneStrikes + " " + Action.STRIKE.getEmoji() + "`\n\n")
+ "@\u0435very1 Attempt: `" + settings.everyoneStrikes + " " + Action.STRIKE.getEmoji() + "`\n\n")
+ "__Miscellaneous__\n"
+ "Auto AntiRaid: " + (settings.useAutoRaidMode()
? "`" + settings.raidmodeNumber + "` joins/`" + settings.raidmodeTime + "`s\n"
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 d736136..33a77a8 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java
@@ -96,7 +96,7 @@
+ "\nVoice Log: "+(voicelog==null ? "None" : voicelog.getAsMention())
+ "\nAvatar Log: "+(avylog==null ? "None" : avylog.getAsMention())
+ "\nServer Log: "+(serverlog==null ? "None" : serverlog.getAsMention())
- + "\nTimezone: **"+settings.timezone+"**\n\u200B", true);
+ + "\nTZone: **"+settings.timezone+"**\n\u200B", true);
}
public boolean hasSettings(Guild guild)
diff --git a/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java b/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java
index 02e995b..e3753bd 100644
--- a/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java
+++ b/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java
@@ -15,7 +15,7 @@
*/
package com.jagrosh.vortex.logging;
-import com.jagrosh.vortex.utils.AvatarUtil;
+import com.jagrosh.vortex.pro.AvatarUtil;
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.logging.MessageCache.CachedMessage;
import com.jagrosh.vortex.utils.FormatUtil;
@@ -131,7 +131,7 @@
.setColor(Color.RED)
.appendDescription(formatted);
User author = oldMessage.getAuthor(vortex.getShardManager());
- String user = author==null ? FormatUtil.formatFullUserId(oldMessage.getAuthorId()) : FormatUtil.formatFullUser(author);
+ String user = author==null ? FormatUtil.formatCachedMessageFullUser(oldMessage) : FormatUtil.formatFullUser(author);
log(OffsetDateTime.now(), tc, "\u274C", user+"'s message has been deleted from "+mtc.getAsMention()+":", delete.build());
}
@@ -160,7 +160,7 @@
.setColor(Color.RED)
.appendDescription(formatted);
User author = messages.get(0).getAuthor(vortex.getShardManager());
- String user = author==null ? FormatUtil.formatFullUserId(messages.get(0).getAuthorId()) : FormatUtil.formatFullUser(author);
+ String user = author==null ? FormatUtil.formatCachedMessageFullUser(messages.get(0)) : FormatUtil.formatFullUser(author);
log(OffsetDateTime.now(), tc, "\u274C", user+"'s message has been deleted from "+mtc.getAsMention()+":", delete.build());
return;
}
diff --git a/src/main/java/com/jagrosh/vortex/logging/MessageCache.java b/src/main/java/com/jagrosh/vortex/logging/MessageCache.java
index 05ec753..7835068 100644
--- a/src/main/java/com/jagrosh/vortex/logging/MessageCache.java
+++ b/src/main/java/com/jagrosh/vortex/logging/MessageCache.java
@@ -57,7 +57,7 @@
public class CachedMessage implements ISnowflake
{
- private final String content;
+ private final String content, username, discriminator;
private final long id, author, channel, guild;
private final List attachments;
@@ -66,6 +66,8 @@
content = message.getContentRaw();
id = message.getIdLong();
author = message.getAuthor().getIdLong();
+ username = message.getAuthor().getName();
+ discriminator = message.getAuthor().getDiscriminator();
channel = message.getChannel().getIdLong();
guild = message.getGuild()==null ? 0L : message.getGuild().getIdLong();
attachments = message.getAttachments();
@@ -86,6 +88,16 @@
return shardManager.getUserById(author);
}
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public String getDiscriminator()
+ {
+ return discriminator;
+ }
+
public long getAuthorId()
{
return author;
diff --git a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java
index 42c190a..330f716 100644
--- a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java
+++ b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java
@@ -25,12 +25,14 @@
import com.jagrosh.vortex.utils.LogUtil.ParsedAuditReason;
import java.time.OffsetDateTime;
import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import net.dv8tion.jda.core.MessageBuilder;
import net.dv8tion.jda.core.Permission;
@@ -39,6 +41,8 @@
import net.dv8tion.jda.core.audit.AuditLogKey;
import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.exceptions.PermissionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -46,6 +50,7 @@
*/
public class ModLogger
{
+ private final static Logger LOG = LoggerFactory.getLogger(ModLogger.class);
private final HashMap caseNum = new HashMap<>();
private final HashSet needsUpdate = new HashSet<>();
private final FixedCache banLogCache = new FixedCache<>(1000);
@@ -62,6 +67,7 @@
if(isStarted)
return;
isStarted=true;
+
vortex.getThreadpool().scheduleWithFixedDelay(()->
{
Set toUpdate;
@@ -70,8 +76,18 @@
toUpdate = new HashSet<>(needsUpdate);
needsUpdate.clear();
}
- toUpdate.forEach(gid -> update(vortex.getShardManager().getGuildById(gid), 30));
- }, 0, 2, TimeUnit.SECONDS);
+ if(!toUpdate.isEmpty())
+ {
+ try
+ {
+ toUpdate.forEach(gid -> update(vortex.getShardManager().getGuildById(gid), 40));
+ } catch(Exception ex)
+ {
+ LOG.error("Exception thrown during modlog update loop: "+ex);
+ ex.printStackTrace();
+ }
+ }
+ }, 0, 3, TimeUnit.SECONDS);
}
public void setNeedUpdate(Guild guild)
@@ -84,7 +100,7 @@
{
needsUpdate.add(guild.getIdLong());
}
- }, 1, TimeUnit.SECONDS);
+ }, 2, TimeUnit.SECONDS);
}
public int updateCase(Guild guild, int num, String reason)
@@ -199,7 +215,7 @@
Role mRole = gs.getMutedRole(guild);
try
{
- List list = guild.getAuditLogs().cache(false).limit(limit).complete();
+ List list = guild.getAuditLogs().cache(false).limit(limit).submit().get(30, TimeUnit.SECONDS);
for(AuditLogEntry ale: vortex.getDatabase().auditcache.filterUncheckedEntries(list))
{
Action act = null;
@@ -288,8 +304,13 @@
}
}
}
+ catch (TimeoutException ex)
+ {
+ LOG.warn("Retreiving audit logs for "+guild+" took longer than 30 seconds!");
+ }
catch(Exception ex)
{
+ LOG.error("Exception thrown during modlog update: "+ex);
ex.printStackTrace();
}
}
diff --git a/src/main/java/com/jagrosh/vortex/logging/TextUploader.java b/src/main/java/com/jagrosh/vortex/logging/TextUploader.java
index b5f7afb..2069816 100644
--- a/src/main/java/com/jagrosh/vortex/logging/TextUploader.java
+++ b/src/main/java/com/jagrosh/vortex/logging/TextUploader.java
@@ -59,7 +59,7 @@
List list = category.getTextChannels();
list.get(index % list.size()).sendFile(content.getBytes(StandardCharsets.UTF_8), filename+".txt", null).queue(
m -> done.consume(
- "http://txt.discord.website?txt="+m.getAttachments().get(0).getUrl().substring(m.getAttachments().get(0).getUrl().indexOf("s/")+2, m.getAttachments().get(0).getUrl().length()-4),
+ "https://txt.discord.website?txt="+m.getAttachments().get(0).getUrl().substring(m.getAttachments().get(0).getUrl().indexOf("s/")+2, m.getAttachments().get(0).getUrl().length()-4),
m.getAttachments().get(0).getUrl()),
f -> LOG.error("Failed to upload: "+f));
index++;
diff --git a/src/main/java/com/jagrosh/vortex/utils/BlockingSessionController.java b/src/main/java/com/jagrosh/vortex/utils/BlockingSessionController.java
index 12fe711..332b30c 100644
--- a/src/main/java/com/jagrosh/vortex/utils/BlockingSessionController.java
+++ b/src/main/java/com/jagrosh/vortex/utils/BlockingSessionController.java
@@ -25,7 +25,7 @@
*/
public class BlockingSessionController extends SessionControllerAdapter
{
- private final int MAX_DELAY = 20*1000;
+ private final int MAX_DELAY = 30*1000;
@Override
protected void runWorker()
diff --git a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
index 06cb94f..14bf8d6 100644
--- a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
@@ -45,7 +45,7 @@
public static String filterEveryone(String input)
{
- return input.replace("@everyone","@\u0435veryone").replace("@here","@h\u0435re");
+ return input.replace("@everyone","@\u0435veryone").replace("@here","@h\u0435re").replace("discord.gg/", "dis\u0441ord.gg/");
}
public static String formatMessage(Message m)
@@ -67,6 +67,11 @@
return "<@"+userId+"> (ID:"+userId+")";
}
+ public static String formatCachedMessageFullUser(CachedMessage msg)
+ {
+ return filterEveryone("**"+msg.getUsername()+"**#"+msg.getDiscriminator()+" (ID:"+msg.getAuthorId()+")");
+ }
+
public static String formatUser(User user)
{
return filterEveryone("**"+user.getName()+"**#"+user.getDiscriminator());
@@ -285,12 +290,16 @@
"[**"+cmd.getHelp()+"**]("+Constants.Wiki.COMMANDS+"#-"+(cmd.getCategory()==null?"general":cmd.getCategory().getName().toLowerCase())+"-commands)\n\u200B", false));
}
- builder.addField("Additional Help", "\uD83D\uDD17 ["+event.getSelfUser().getName()+" Wiki]("+Constants.Wiki.WIKI_BASE+")\n"
- + "<:discord:314003252830011395> [Support Server]("+event.getClient().getServerInvite()+")\n"
- + "\uD83D\uDCDC [Full Command Reference]("+Constants.Wiki.COMMANDS+")\n"
- + "<:patreon:417455429145329665> [Donations]("+Constants.DONATION_LINK+")", false);
+ builder.addField("Additional Help", helpLinks(event), false);
return new MessageBuilder().append(content).setEmbed(builder.build()).build();
}
+ public static String helpLinks(CommandEvent event)
+ {
+ return "\uD83D\uDD17 ["+event.getSelfUser().getName()+" Wiki]("+Constants.Wiki.WIKI_BASE+")\n"
+ + "<:discord:314003252830011395> [Support Server]("+event.getClient().getServerInvite()+")\n"
+ + "\uD83D\uDCDC [Full Command Reference]("+Constants.Wiki.COMMANDS+")\n"
+ + "<:patreon:417455429145329665> [Donations]("+Constants.DONATION_LINK+")";
+ }
}
diff --git a/src/main/java/com/jagrosh/vortex/utils/LogUtil.java b/src/main/java/com/jagrosh/vortex/utils/LogUtil.java
index 15be492..fec361f 100644
--- a/src/main/java/com/jagrosh/vortex/utils/LogUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/LogUtil.java
@@ -146,7 +146,7 @@
.append(m.getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME))
.append("] ");
if(author==null)
- sb.append("Unknown User#0000 (").append(m.getAuthorId());
+ sb.append(m.getUsername()).append("#").append(m.getDiscriminator()).append(" (").append(m.getAuthorId());
else
sb.append(author.getName()).append("#").append(author.getDiscriminator()).append(" (").append(author.getId());
sb.append(") : ").append(m.getContentRaw());