diff --git a/pom.xml b/pom.xml
index a0855a2..b6677c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
net.dv8tion
JDA
- 3.5.1_339
+ 3.5.1_341
com.jagrosh
diff --git a/src/main/java/com/jagrosh/vortex/Constants.java b/src/main/java/com/jagrosh/vortex/Constants.java
index 5c9104a..a36bbbd 100644
--- a/src/main/java/com/jagrosh/vortex/Constants.java
+++ b/src/main/java/com/jagrosh/vortex/Constants.java
@@ -15,6 +15,7 @@
*/
package com.jagrosh.vortex;
+import com.jagrosh.jdautilities.command.Command.Category;
import java.time.OffsetDateTime;
import net.dv8tion.jda.core.Permission;
@@ -31,6 +32,7 @@
public final static String ERROR = "<:vError:390229421228949504>";
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 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,
@@ -40,12 +42,36 @@
//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";
- public final static class WIKI
+ public final static class Wiki
{
- public final static String WIKI_BASE = "https://github.com/jagrosh/Vortex/wiki/";
- public final static String LOG_TIMEZONE = WIKI_BASE + "/Log-Timezone";
- public final static String RAID_MODE = WIKI_BASE + "/Raid-Mode";
- public final static String FULL_COMMAND_REFERENCE = WIKI_BASE + "/Full-Command-Reference";
+ 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 LOG_TIMEZONE = WIKI_BASE + "/Log-Timezone";
+ public final static String RAID_MODE = WIKI_BASE + "/Raid-Mode";
+ public final static String COMMANDS = WIKI_BASE + "/Commands";
+
+ public final static class Shortened
+ {
+ public final static String GENERAL_COMMANDS = "https://git.io/vArzg";
+ public final static String MODERATOR_COMMANDS = "https://git.io/vArza";
+ public final static String SETTINGS_COMMANDS = "https://git.io/vArzV";
+ public final static String AUTOMOD_COMMANDS = "https://git.io/vArzr";
+
+ public static String fromCategory(Category category)
+ {
+ if(category==null)
+ return GENERAL_COMMANDS;
+ switch(category.getName().toLowerCase())
+ {
+ case "moderation": return MODERATOR_COMMANDS;
+ case "settings": return SETTINGS_COMMANDS;
+ case "automod": return AUTOMOD_COMMANDS;
+ default: return GENERAL_COMMANDS;
+ }
+ }
+ }
}
}
diff --git a/src/main/java/com/jagrosh/vortex/Listener.java b/src/main/java/com/jagrosh/vortex/Listener.java
index f508b34..05d6226 100644
--- a/src/main/java/com/jagrosh/vortex/Listener.java
+++ b/src/main/java/com/jagrosh/vortex/Listener.java
@@ -132,8 +132,10 @@
}
else if (event instanceof GuildUnbanEvent)
{
+ GuildUnbanEvent gue = (GuildUnbanEvent) event;
// Signal the modlogger because someone was unbanned
- vortex.getModLogger().setNeedUpdate(((GuildUnbanEvent) event).getGuild());
+ vortex.getDatabase().tempbans.clearBan(gue.getGuild(), gue.getUser().getIdLong());
+ vortex.getModLogger().setNeedUpdate((gue).getGuild());
}
else if (event instanceof GuildMemberRoleAddEvent)
{
@@ -149,7 +151,10 @@
// Signal the modlogger if someone was unmuted
if(gmrre.getRoles().stream().anyMatch(r -> r.getName().equalsIgnoreCase("muted")))
+ {
+ vortex.getDatabase().tempmutes.removeMute(gmrre.getGuild(), gmrre.getUser().getIdLong());
vortex.getModLogger().setNeedUpdate(gmrre.getGuild());
+ }
}
else if (event instanceof UserNameUpdateEvent)
{
diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java
index 28e21aa..40d7384 100644
--- a/src/main/java/com/jagrosh/vortex/Vortex.java
+++ b/src/main/java/com/jagrosh/vortex/Vortex.java
@@ -15,13 +15,7 @@
*/
package com.jagrosh.vortex;
-import com.jagrosh.vortex.commands.automod.AntimentionCmd;
-import com.jagrosh.vortex.commands.automod.AntiduplicateCmd;
-import com.jagrosh.vortex.commands.automod.AutoraidmodeCmd;
-import com.jagrosh.vortex.commands.settings.SettingsCmd;
-import com.jagrosh.vortex.commands.automod.AntiinviteCmd;
-import com.jagrosh.vortex.commands.automod.UnignoreCmd;
-import com.jagrosh.vortex.commands.automod.IgnoreCmd;
+import com.jagrosh.vortex.commands.automod.*;
import com.jagrosh.vortex.commands.general.*;
import com.jagrosh.vortex.commands.moderation.*;
import com.jagrosh.vortex.commands.owner.*;
@@ -104,11 +98,11 @@
.setEmojis(Constants.SUCCESS, Constants.WARNING, Constants.ERROR)
.setLinkedCacheSize(0)
.setGuildSettingsManager(database.settings)
- .addCommands(
- // General
+ .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 InviteCmd(),
+ new LookupCmd(this),
new PingCommand(),
new ServerinfoCmd(),
new UserinfoCmd(),
@@ -139,7 +133,8 @@
// Automoderation
new AntiinviteCmd(this),
- new AntimentionCmd(this),
+ new MaxlinesCmd(this),
+ new MaxmentionsCmd(this),
new AntiduplicateCmd(this),
new AutoraidmodeCmd(this),
new IgnoreCmd(this),
diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
index d081fe6..d8b30d1 100644
--- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
+++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
@@ -47,7 +47,7 @@
public class AutoMod
{
private final static Pattern INVITES = Pattern.compile("discord\\s?(?:\\.\\s?gg|app\\s?.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})",Pattern.CASE_INSENSITIVE);
- private final static Pattern REF = Pattern.compile("");
+ //private final static Pattern REF = Pattern.compile("");
private final static String CONDENSER = "(.+?)\\s*(\\1\\s*)+";
private final static Logger LOG = LoggerFactory.getLogger("AutoMod");
@@ -203,17 +203,14 @@
if(settings==null)
return;
- /*
- check for automod actions
- * AntiDuplicate - prevent repeated messages
- * AntiMention - prevent mass-mention spammers
- * AntiInvite - prevent invite links to other servers
- */
+ // 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}");
boolean shouldDelete = false;
// anti-duplicate
- if(settings.useAntiDuplicate() && (message.getTextChannel().getTopic()==null || !message.getTextChannel().getTopic().toLowerCase().contains("{spam}")))
+ if(settings.useAntiDuplicate() && preventSpam)
{
String key = message.getAuthor().getId()+"|"+message.getGuild().getId();
String content = condensedContent(message);
@@ -241,7 +238,8 @@
// anti-mention (users)
if(settings.maxMentions>=AutomodManager.MENTION_MINIMUM)
{
- long mentions = message.getMentionedUsers().stream().filter(u -> !u.isBot() && !u.equals(message.getAuthor())).count();
+
+ long mentions = message.getMentionedUsers().stream().filter(u -> !u.isBot() && !u.equals(message.getAuthor())).distinct().count();
if(mentions > settings.maxMentions)
{
vortex.getStrikeHandler().applyStrikes(message.getGuild().getSelfMember(), latestTime(message),
@@ -250,6 +248,18 @@
}
}
+ // max newlines
+ if(settings.maxLines>0 && preventSpam)
+ {
+ int count = message.getContentRaw().split("\n").length;
+ if(count > settings.maxLines)
+ {
+ vortex.getStrikeHandler().applyStrikes(message.getGuild().getSelfMember(), latestTime(message),
+ message.getAuthor(), count-settings.maxLines, "Message contained "+count+" newlines");
+ shouldDelete = true;
+ }
+ }
+
// anti-mention (roles)
if(settings.maxRoleMentions >= AutomodManager.ROLE_MENTION_MINIMUM)
{
@@ -263,7 +273,7 @@
}
// anti-invite
- if(settings.inviteStrikes > 0 && (message.getTextChannel().getTopic()==null || !message.getTextChannel().getTopic().toLowerCase().contains("{invites}")))
+ if(settings.inviteStrikes > 0 && preventInvites)
{
List invites = new ArrayList<>();
Matcher m = INVITES.matcher(message.getContentRaw());
@@ -303,7 +313,7 @@
{
try
{
- m.delete().queue();
+ m.delete().queue(s->{}, f->{});
}
catch(PermissionException ex) {}
});
diff --git a/src/main/java/com/jagrosh/vortex/automod/Filter.java b/src/main/java/com/jagrosh/vortex/automod/Filter.java
new file mode 100644
index 0000000..5f643b3
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/automod/Filter.java
@@ -0,0 +1,85 @@
+/*
+ * 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.automod;
+
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public abstract class Filter
+{
+ public final int strikes;
+ public abstract boolean test(String message);
+
+ private Filter(int strikes)
+ {
+ this.strikes = strikes;
+ }
+
+ public static class WordFilter extends Filter
+ {
+ public final String word;
+
+ public WordFilter(int strikes, String word)
+ {
+ super(strikes);
+ this.word = " "+word.replaceAll("\\s+", " ").toLowerCase()+" ";
+ }
+
+ @Override
+ public boolean test(String message)
+ {
+ return (" "+message.replaceAll("\\s+", " ").toLowerCase()+" ").contains(word);
+ }
+ }
+
+ public static class GlobFilter extends Filter
+ {
+ public final String glob;
+
+ public GlobFilter(int strikes, String glob)
+ {
+ super(strikes);
+ this.glob = glob.replaceAll("\\s+", " ").toLowerCase();
+ }
+
+ @Override
+ public boolean test(String message)
+ {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+ }
+
+ public static class RegexFilter extends Filter
+ {
+ public final Pattern pattern;
+
+ public RegexFilter(int strikes, String pattern) throws PatternSyntaxException
+ {
+ super(strikes);
+ this.pattern = Pattern.compile(pattern);
+ }
+
+ @Override
+ public boolean test(String message)
+ {
+ return pattern.matcher(message).find();
+ }
+ }
+}
diff --git a/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java b/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java
index 005f7c8..26b1541 100644
--- a/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java
+++ b/src/main/java/com/jagrosh/vortex/automod/StrikeHandler.java
@@ -68,37 +68,23 @@
public void applyStrikes(Member moderator, OffsetDateTime nowo, User target, int number, String reason)
{
- applyStrikes(moderator, nowo, target.getIdLong(), number, reason);
- }
-
- public void applyStrikes(Member moderator, OffsetDateTime nowo, long targetId, int number, String reason)
- {
- //reason = reason.length()>400 ? reason.substring(0, 400) : reason;
Instant now = nowo.toInstant();
- int[] counts = vortex.getDatabase().strikes.addStrikes(moderator.getGuild(), targetId, number);
+ int[] counts = vortex.getDatabase().strikes.addStrikes(moderator.getGuild(), target.getIdLong(), number);
List punishments = vortex.getDatabase().actions.getPunishments(moderator.getGuild(), counts[0], counts[1]);
- User user = vortex.getShardManager().getUserById(targetId);
String dmmsg = String.format(STRIKE_FORMAT, number, moderator.getGuild().getName(), reason);
if(punishments.isEmpty())
{
- if(user==null)
- {
- moderator.getJDA().retrieveUserById(targetId).queue(u -> vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], u, reason));
- }
- else
- {
- vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], user, reason);
- OtherUtil.safeDM(user, dmmsg, ()->{});
- }
+ vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], target, reason);
+ OtherUtil.safeDM(target, dmmsg, ()->{});
}
else
{
- String notimeaudit = LogUtil.auditStrikeReasonFormat(moderator, 0, counts[1], reason);
+ String notimeaudit = LogUtil.auditStrikeReasonFormat(moderator, 0, counts[0], counts[1], reason);
if(punishments.stream().anyMatch(p -> p.action==Action.BAN))
{
- OtherUtil.safeDM(user, dmmsg + punish(Action.BAN, moderator.getGuild()),
- () -> moderator.getGuild().getController().ban(Long.toString(targetId), 7, notimeaudit).queue());
- vortex.getDatabase().tempbans.clearBan(moderator.getGuild(), targetId);
+ OtherUtil.safeDM(target, dmmsg + punish(Action.BAN, moderator.getGuild()),
+ () -> moderator.getGuild().getController().ban(target, 7, notimeaudit).queue());
+ vortex.getDatabase().tempbans.clearBan(moderator.getGuild(), target.getIdLong());
return;
}
int muteDuration = 0;
@@ -115,61 +101,61 @@
if(banDuration>0)
{
int finalBanDuration = banDuration;
- OtherUtil.safeDM(user, dmmsg + punishTime(Action.TEMPBAN, moderator.getGuild(), banDuration),
- () -> moderator.getGuild().getController().ban(Long.toString(targetId), 7, LogUtil.auditStrikeReasonFormat(moderator, finalBanDuration, counts[1], reason)).queue());
- vortex.getDatabase().tempbans.setBan(moderator.getGuild(), targetId, now.plus(banDuration, ChronoUnit.MINUTES));
+ OtherUtil.safeDM(target, dmmsg + punishTime(Action.TEMPBAN, moderator.getGuild(), banDuration),
+ () -> 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)
- vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), targetId, muteTime(now, muteDuration));
+ vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), target.getIdLong(), muteTime(now, muteDuration));
return;
}
if(punishments.stream().anyMatch(p -> p.action==Action.SOFTBAN))
{
- OtherUtil.safeDM(user, dmmsg + punish(Action.SOFTBAN, moderator.getGuild()),
- () -> moderator.getGuild().getController().ban(Long.toString(targetId), 7, notimeaudit).queue(
- s -> moderator.getGuild().getController().unban(Long.toString(targetId)).reason(notimeaudit).queueAfter(5, TimeUnit.SECONDS)));
+ OtherUtil.safeDM(target, dmmsg + punish(Action.SOFTBAN, moderator.getGuild()),
+ () -> moderator.getGuild().getController().ban(target, 7, notimeaudit).queue(
+ s -> moderator.getGuild().getController().unban(target).reason(notimeaudit).queueAfter(5, TimeUnit.SECONDS)));
if(muteDuration>0)
- vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), targetId, muteTime(now, muteDuration));
+ vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), target.getIdLong(), muteTime(now, muteDuration));
return;
}
if(punishments.stream().anyMatch(p -> p.action==Action.KICK))
{
- if(user!=null && moderator.getGuild().isMember(user))
+ if(moderator.getGuild().isMember(target))
{
- OtherUtil.safeDM(user, dmmsg + punish(Action.KICK, moderator.getGuild()),
- () -> moderator.getGuild().getController().kick(Long.toString(targetId), notimeaudit).queue());
+ OtherUtil.safeDM(target, dmmsg + punish(Action.KICK, moderator.getGuild()),
+ () -> moderator.getGuild().getController().kick(target.getId(), notimeaudit).queue());
}
else
{
- vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], user, reason);
+ vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], target, reason);
}
if(muteDuration>0)
- vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), targetId, muteTime(now, muteDuration));
+ vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), target.getIdLong(), muteTime(now, muteDuration));
return;
}
if(muteDuration>0)
{
- vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), targetId, muteTime(now, muteDuration));
+ vortex.getDatabase().tempmutes.setMute(moderator.getGuild(), target.getIdLong(), muteTime(now, muteDuration));
Role muted = moderator.getGuild().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("Muted")).findFirst().orElse(null);
- Member mem = moderator.getGuild().getMemberById(targetId);
- if(muted==null || mem==null)
+ Member mem = moderator.getGuild().getMember(target);
+ if(muted==null || mem==null || !moderator.getGuild().getSelfMember().canInteract(muted))
{
- vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], user, reason);
- OtherUtil.safeDM(user, dmmsg, ()->{});
+ vortex.getModLogger().postStrikeCase(moderator, nowo, number, counts[0], counts[1], target, reason);
+ OtherUtil.safeDM(target, dmmsg, ()->{});
return;
}
if(mem.getRoles().contains(muted))
{
vortex.getModLogger().postPseudoCase(moderator, nowo,
- muteDuration==Integer.MAX_VALUE ? Action.MUTE : Action.TEMPMUTE, user,
+ muteDuration==Integer.MAX_VALUE ? Action.MUTE : Action.TEMPMUTE, target,
muteDuration==Integer.MAX_VALUE ? 0 : muteDuration, "["+counts[1]+" strikes] "+reason);
}
else
{
moderator.getGuild().getController().addSingleRoleToMember(mem, muted)
- .reason(muteDuration==Integer.MAX_VALUE ? notimeaudit : LogUtil.auditStrikeReasonFormat(moderator, muteDuration, counts[1], reason))
+ .reason(muteDuration==Integer.MAX_VALUE ? notimeaudit : LogUtil.auditStrikeReasonFormat(moderator, muteDuration, counts[0], counts[1], reason))
.queue();
}
- OtherUtil.safeDM(user, dmmsg + (muteDuration==Integer.MAX_VALUE ? punish(Action.MUTE, moderator.getGuild())
+ OtherUtil.safeDM(target, dmmsg + (muteDuration==Integer.MAX_VALUE ? punish(Action.MUTE, moderator.getGuild())
: punishTime(Action.TEMPMUTE, moderator.getGuild(), muteDuration)), ()->{});
}
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/ModCommand.java b/src/main/java/com/jagrosh/vortex/commands/ModCommand.java
index b6ece0c..98df964 100644
--- a/src/main/java/com/jagrosh/vortex/commands/ModCommand.java
+++ b/src/main/java/com/jagrosh/vortex/commands/ModCommand.java
@@ -16,6 +16,7 @@
package com.jagrosh.vortex.commands;
import com.jagrosh.jdautilities.command.Command;
+import com.jagrosh.vortex.Constants;
import com.jagrosh.vortex.Vortex;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Role;
@@ -41,9 +42,27 @@
Role modrole = vortex.getDatabase().settings.getSettings(event.getGuild()).getModeratorRole(event.getGuild());
if(modrole!=null && event.getMember().getRoles().contains(modrole))
return true;
- if(event.getMember().hasPermission(altPerms))
+
+ boolean missingPerms = false;
+ for(Permission altPerm: altPerms)
+ {
+ if(altPerm.isText())
+ {
+ if(!event.getMember().hasPermission(event.getTextChannel(), altPerm))
+ missingPerms = true;
+ }
+ else
+ {
+ if(!event.getMember().hasPermission(altPerm))
+ missingPerms = true;
+ }
+ }
+ if(!missingPerms)
return true;
- event.replyError("You must have the following permissions to use that: "+listPerms(altPerms));
+ if(event.getMember().getRoles().isEmpty())
+ event.getMessage().addReaction(Constants.ERROR_REACTION).queue();
+ else
+ event.replyError("You must have the following permissions to use that: "+listPerms(altPerms));
return false;
});
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AntiduplicateCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AntiduplicateCmd.java
index 94cc39e..9901715 100644
--- a/src/main/java/com/jagrosh/vortex/commands/automod/AntiduplicateCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntiduplicateCmd.java
@@ -34,6 +34,7 @@
{
this.vortex = vortex;
this.name = "antiduplicate";
+ this.aliases = new String[]{"antidupe","anti-duplicate","anti-dupe"};
this.guildOnly = true;
this.category = new Category("AutoMod");
this.arguments = " [delete threshold] [strikes] or OFF";
diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AntimentionCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AntimentionCmd.java
deleted file mode 100644
index bcde2f4..0000000
--- a/src/main/java/com/jagrosh/vortex/commands/automod/AntimentionCmd.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2018 John Grosh (john.a.grosh@gmail.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.jagrosh.vortex.commands.automod;
-
-import com.jagrosh.jdautilities.command.Command;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import com.jagrosh.vortex.Constants;
-import com.jagrosh.vortex.Vortex;
-import net.dv8tion.jda.core.Permission;
-import com.jagrosh.vortex.database.managers.AutomodManager;
-import com.jagrosh.vortex.database.managers.PunishmentManager;
-
-/**
- *
- * @author John Grosh (john.a.grosh@gmail.com)
- */
-public class AntimentionCmd extends Command
-{
- private final Vortex vortex;
-
- public AntimentionCmd(Vortex vortex)
- {
- this.vortex = vortex;
- this.guildOnly = true;
- this.name = "maxmentions";
- this.aliases = new String[]{"antimention","maxmention","mentionmax","mentionsmax"};
- this.category = new Category("AutoMod");
- this.arguments = "";
- this.help = "sets max mentions a user can send";
- this.userPermissions = new Permission[]{Permission.MANAGE_SERVER};
- this.children = new Command[]{new AntirolementionCmd()};
- }
-
- @Override
- protected void execute(CommandEvent event)
- {
- if(event.getArgs().equalsIgnoreCase("off") || event.getArgs().equalsIgnoreCase("none"))
- {
- vortex.getDatabase().automod.disableMaxMentions(event.getGuild());
- event.replySuccess("Anti-Mention has been disabled.");
- return;
- }
- else if(event.getArgs().isEmpty())
- {
- event.replyError("Please include an integer value or `OFF`");
- return;
- }
- try
- {
- short num = Short.parseShort(event.getArgs());
- if(num` must be a valid integer at least `"+AutomodManager.MENTION_MINIMUM+"`");
- }
- }
-
- private class AntirolementionCmd extends Command
- {
- public AntirolementionCmd()
- {
- this.guildOnly = true;
- this.name = "roles";
- this.aliases = new String[]{"role"};
- this.category = new Category("AutoMod");
- this.arguments = "";
- this.help = "sets maximum number of unique role mentions a user can send";
- this.userPermissions = new Permission[]{Permission.MANAGE_SERVER};
- }
-
- @Override
- protected void execute(CommandEvent event)
- {
- if(event.getArgs().isEmpty())
- {
- event.replyError("Please include an integer value or `OFF`");
- return;
- }
- try
- {
- short num = Short.parseShort(event.getArgs());
- if(num` must be a valid integer at least `"+AutomodManager.ROLE_MENTION_MINIMUM+"`");
- }
- }
- }
-}
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 08c6bf0..0251f2c 100644
--- a/src/main/java/com/jagrosh/vortex/commands/automod/AutoraidmodeCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/automod/AutoraidmodeCmd.java
@@ -64,7 +64,7 @@
+ "\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 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+">");
+ + "\nFor more information, check out the wiki: <"+Constants.Wiki.RAID_MODE+">");
return;
}
else
diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/BlacklistCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/BlacklistCmd.java
new file mode 100644
index 0000000..103c32e
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/automod/BlacklistCmd.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2018 John Grosh (john.a.grosh@gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jagrosh.vortex.commands.automod;
+
+import com.jagrosh.jdautilities.command.Command;
+import com.jagrosh.jdautilities.command.CommandEvent;
+import com.jagrosh.vortex.Vortex;
+import net.dv8tion.jda.core.Permission;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public class BlacklistCmd extends Command
+{
+ private final Vortex vortex;
+
+ public BlacklistCmd(Vortex vortex)
+ {
+ this.vortex = vortex;
+ this.guildOnly = true;
+ this.name = "blacklist";
+ this.category = new Category("AutoMod");
+ this.arguments = "[word]";
+ this.help = "shows/edits the word blacklist";
+ this.userPermissions = new Permission[]{Permission.MANAGE_SERVER};
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+
+ }
+}
diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java
new file mode 100644
index 0000000..8aa45bd
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/automod/MaxlinesCmd.java
@@ -0,0 +1,67 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.jagrosh.vortex.commands.automod;
+
+import com.jagrosh.jdautilities.command.Command;
+import com.jagrosh.jdautilities.command.CommandEvent;
+import net.dv8tion.jda.core.Permission;
+import com.jagrosh.vortex.Vortex;
+import com.jagrosh.vortex.database.managers.AutomodManager;
+import com.jagrosh.vortex.database.managers.PunishmentManager;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public class MaxlinesCmd extends Command
+{
+ private final Vortex vortex;
+
+ public MaxlinesCmd(Vortex vortex)
+ {
+ this.vortex = vortex;
+ this.name = "maxlines";
+ this.guildOnly = true;
+ this.aliases = new String[]{"maxnewlines"};
+ this.category = new Category("AutoMod");
+ this.arguments = "";
+ this.help = "sets maximum lines allowed per message";
+ this.userPermissions = new Permission[]{Permission.MANAGE_SERVER};
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ if(event.getArgs().isEmpty())
+ {
+ event.replyError("Please provide a maximum number of newlines allowed!");
+ return;
+ }
+ int maxlines;
+ try
+ {
+ maxlines = Integer.parseInt(event.getArgs());
+ }
+ catch(NumberFormatException ex)
+ {
+ if(event.getArgs().equalsIgnoreCase("none") || event.getArgs().equalsIgnoreCase("off"))
+ maxlines = 0;
+ else
+ {
+ event.replyError("`"+event.getArgs()+"` is not a valid integer!");
+ return;
+ }
+ }
+ if(maxlines<0)
+ {
+ event.replyError("The maximum number of lines must be a positive integer!");
+ return;
+ }
+ vortex.getDatabase().automod.setMaxLines(event.getGuild(), maxlines);
+ boolean also = vortex.getDatabase().actions.useDefaultSettings(event.getGuild());
+ event.replySuccess("Messages longer than `"+maxlines+"` lines will now be automatically deleted, and users will receive strikes for every additional line."+(also ? PunishmentManager.DEFAULT_SETUP_MESSAGE : ""));
+ }
+}
diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/MaxmentionsCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/MaxmentionsCmd.java
new file mode 100644
index 0000000..7a9ce2f
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/automod/MaxmentionsCmd.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2018 John Grosh (john.a.grosh@gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jagrosh.vortex.commands.automod;
+
+import com.jagrosh.jdautilities.command.Command;
+import com.jagrosh.jdautilities.command.CommandEvent;
+import com.jagrosh.vortex.Constants;
+import com.jagrosh.vortex.Vortex;
+import net.dv8tion.jda.core.Permission;
+import com.jagrosh.vortex.database.managers.AutomodManager;
+import com.jagrosh.vortex.database.managers.PunishmentManager;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public class MaxmentionsCmd extends Command
+{
+ private final Vortex vortex;
+
+ public MaxmentionsCmd(Vortex vortex)
+ {
+ this.vortex = vortex;
+ this.guildOnly = true;
+ this.name = "maxmentions";
+ this.aliases = new String[]{"antimention","maxmention","mentionmax","mentionsmax"};
+ this.category = new Category("AutoMod");
+ this.arguments = "";
+ this.help = "sets max mentions a user can send";
+ this.userPermissions = new Permission[]{Permission.MANAGE_SERVER};
+ this.children = new Command[]{new AntirolementionCmd()};
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ if(event.getArgs().equalsIgnoreCase("off") || event.getArgs().equalsIgnoreCase("none"))
+ {
+ vortex.getDatabase().automod.disableMaxMentions(event.getGuild());
+ event.replySuccess("Anti-Mention has been disabled.");
+ return;
+ }
+ else if(event.getArgs().isEmpty())
+ {
+ event.replyError("Please include an integer value or `OFF`");
+ return;
+ }
+ try
+ {
+ short num = Short.parseShort(event.getArgs());
+ if(num` must be a valid integer at least `"+AutomodManager.MENTION_MINIMUM+"`");
+ }
+ }
+
+ private class AntirolementionCmd extends Command
+ {
+ public AntirolementionCmd()
+ {
+ this.guildOnly = true;
+ this.name = "roles";
+ this.aliases = new String[]{"role"};
+ this.category = new Category("AutoMod");
+ this.arguments = "";
+ this.help = "sets maximum number of unique role mentions a user can send";
+ this.userPermissions = new Permission[]{Permission.MANAGE_SERVER};
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ if(event.getArgs().equalsIgnoreCase("off") || event.getArgs().equalsIgnoreCase("none"))
+ {
+ vortex.getDatabase().automod.setMaxRoleMentions(event.getGuild(), 0);
+ event.replySuccess("Anti-Mention for Role mentions has been disabled.");
+ return;
+ }
+ if(event.getArgs().isEmpty())
+ {
+ event.replyError("Please include an integer value or `OFF`");
+ return;
+ }
+ try
+ {
+ short num = Short.parseShort(event.getArgs());
+ if(num` must be a valid integer at least `"+AutomodManager.ROLE_MENTION_MINIMUM+"`");
+ }
+ }
+ }
+}
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 9f40d0e..23dcf47 100644
--- a/src/main/java/com/jagrosh/vortex/commands/general/InviteCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/general/InviteCmd.java
@@ -37,7 +37,7 @@
event.reply("Hello. I am **"+event.getJDA().getSelfUser().getName()+"**, a simple moderation bot built by **jagrosh**#4824."
+ "\nYou can add me to your server with the link below:"
+ "\n\n\uD83D\uDD17 **<"+Constants.BOT_INVITE+">**"
- + "\n\nFor help or suggestions, please join the support server: "+Constants.SERVER_INVITE);
+ + "\n\nFor assistance, check out the wiki: <"+Constants.Wiki.WIKI_BASE+">");
}
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/general/LookupCmd.java b/src/main/java/com/jagrosh/vortex/commands/general/LookupCmd.java
new file mode 100644
index 0000000..cfe2cb9
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/general/LookupCmd.java
@@ -0,0 +1,177 @@
+/*
+ * 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://wwwidget.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.vortex.Vortex;
+import java.time.format.DateTimeFormatter;
+import net.dv8tion.jda.core.EmbedBuilder;
+import net.dv8tion.jda.core.MessageBuilder;
+import net.dv8tion.jda.core.entities.ChannelType;
+import net.dv8tion.jda.core.entities.Invite;
+import net.dv8tion.jda.core.entities.User;
+import net.dv8tion.jda.core.exceptions.RateLimitedException;
+import net.dv8tion.jda.core.utils.MiscUtil;
+import net.dv8tion.jda.core.utils.WidgetUtil;
+import net.dv8tion.jda.core.utils.WidgetUtil.Widget;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public class LookupCmd extends Command
+{
+ private final Vortex vortex;
+ private final String linestart = "\u25AB";
+
+ public LookupCmd(Vortex vortex)
+ {
+ this.vortex = vortex;
+ this.name = "lookup";
+ this.arguments = "";
+ this.help = "finds information about a user or server";
+ this.cooldown = 5;
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ if(event.getArgs().isEmpty())
+ {
+ event.replyError("Please provide a User ID, Server ID, or Invite Code\n"
+ + "This command provides information about a user or server. "
+ + "All of the information provided is information that Discord makes publically-available.");
+ return;
+ }
+ event.getChannel().sendTyping().queue();
+ event.async(() ->
+ {
+ try
+ {
+ long id = Long.parseLong(event.getArgs());
+ User u = vortex.getShardManager().getUserById(id);
+ if(u==null) try
+ {
+ u = event.getJDA().retrieveUserById(id).complete();
+ }
+ catch(Exception ex) {}
+ if(u!=null)
+ {
+ String text = (u.isBot()?"<:botTag:230105988211015680>":"\uD83D\uDC64")+" Information about **"+u.getName()+"**#"+u.getDiscriminator()+":";
+ EmbedBuilder eb = new EmbedBuilder();
+ eb.setThumbnail(u.getEffectiveAvatarUrl());
+ String str = linestart+"Discord ID: **"+u.getId()+"**";
+ if(u.getAvatarId()!=null && u.getAvatarId().startsWith("a_"))
+ str+= " <:nitro:314068430611415041>";
+ str+="\n"+linestart+"Account Creation: **"+MiscUtil.getDateTimeString(u.getCreationTime())+"**";
+ eb.setDescription(str);
+ event.reply(new MessageBuilder().append(text).setEmbed(eb.build()).build());
+ return;
+ }
+
+ Widget widget = WidgetUtil.getWidget(id);
+ if(widget!=null)
+ {
+ if(!widget.isAvailable())
+ {
+ event.replySuccess("Guild with ID `"+id+"` found; no further information found.");
+ return;
+ }
+ Invite inv = null;
+ if(widget.getInviteCode()!=null)
+ {
+ try
+ {
+ inv = Invite.resolve(event.getJDA(), widget.getInviteCode()).complete();
+ }
+ catch(Exception ex){}
+ }
+ String text = "\uD83D\uDDA5 Information about **"+widget.getName()+"**:";
+ EmbedBuilder eb = new EmbedBuilder();
+ String str = linestart+"ID: **"+widget.getId()+"**\n"
+ +linestart+"Creation: **"+widget.getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n"
+ +linestart+"Channels: **"+widget.getVoiceChannels().size()+"** Voice\n"
+ +linestart+"Users: **"+widget.getMembers().size()+"** online\n";
+ if(inv!=null)
+ {
+ eb.setThumbnail(inv.getGuild().getIconUrl());
+ str+=linestart+"Invite: **"+inv.getCode()+"** "+(inv.getChannel().getType()==ChannelType.TEXT
+ ? "#"+inv.getChannel().getName() : inv.getChannel().getName())+" (ID:"+inv.getChannel().getId()+")";
+ if(inv.getGuild().getSplashId()!=null)
+ {
+ str+="\n\n<:partner:314068430556758017> **Discord Partner** <:partner:314068430556758017>";
+ eb.setImage(inv.getGuild().getSplashUrl()+"?size=1024");
+ }
+ }
+ eb.setDescription(str);
+ event.reply(new MessageBuilder().append(text).setEmbed(eb.build()).build());
+ return;
+ }
+
+ }
+ catch(NumberFormatException ex)
+ {
+ }
+ catch(RateLimitedException ex)
+ {
+ event.reactWarning();
+ return;
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ String code = event.getArgs().substring(event.getArgs().indexOf("/")+1);
+ Invite inv = null;
+ try
+ {
+ inv = Invite.resolve(event.getJDA(), code).complete();
+ }
+ catch(Exception ex){}
+ if(inv==null)
+ {
+ event.replyError("No users, guilds, or invites found.");
+ return;
+ }
+ Widget widget = null;
+ try
+ {
+ widget = WidgetUtil.getWidget(inv.getGuild().getIdLong());
+ }
+ catch(RateLimitedException ex) {}
+ String text = "\uD83D\uDDA5 Information about Invite Code **"+code+"**:";
+ EmbedBuilder eb = new EmbedBuilder();
+ eb.setThumbnail(inv.getGuild().getIconUrl());
+ String str = linestart+"Guild: **"+inv.getGuild().getName()+"**\n"
+ + linestart+"Channel: **"+(inv.getChannel().getType()==ChannelType.TEXT?"#":"")+inv.getChannel().getName()+"** (ID:"+inv.getChannel().getId()+")\n"
+ + linestart+"Inviter: "+(inv.getInviter()==null?"N/A":"**"+inv.getInviter().getName()+"**#"+inv.getInviter().getDiscriminator()+" (ID:"+inv.getInviter().getId()+")");
+ eb.setDescription(str);
+ str = linestart+"ID: **"+inv.getGuild().getId()+"**\n"
+ +linestart+"Creation: **"+inv.getGuild().getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n";
+ if(widget!=null)
+ str += linestart+"Channels: **"+widget.getVoiceChannels().size()+"** Voice\n"
+ +linestart+"Users: **"+widget.getMembers().size()+"** online";
+ if(inv.getGuild().getSplashId()!=null)
+ {
+ str+="\n\n<:partner:314068430556758017> **Discord Partner** <:partner:314068430556758017>";
+ eb.setImage(inv.getGuild().getSplashUrl()+"?size=1024");
+ }
+ eb.addField("Guild Info", str, false);
+ event.reply(new MessageBuilder().append(text).setEmbed(eb.build()).build());
+ });
+ }
+}
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 56b979d..eb47ed4 100644
--- a/src/main/java/com/jagrosh/vortex/commands/general/ServerinfoCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/general/ServerinfoCmd.java
@@ -18,6 +18,7 @@
import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.vortex.utils.FormatUtil;
+import com.jagrosh.vortex.utils.OtherUtil;
import java.time.format.DateTimeFormatter;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.MessageBuilder;
@@ -47,7 +48,7 @@
long onlineCount = guild.getMembers().stream().filter((u) -> (u.getOnlineStatus()!=OnlineStatus.OFFLINE)).count();
long botCount = guild.getMembers().stream().filter(m -> m.getUser().isBot()).count();
EmbedBuilder builder = new EmbedBuilder();
- String title = FormatUtil.filterEveryone("\uD83D\uDDA5 Information about "+guild.getName()+":");
+ String title = FormatUtil.filterEveryone("\uD83D\uDDA5 Information about **"+guild.getName()+"**:");
String verif;
switch(guild.getVerificationLevel()) {
case VERY_HIGH: verif = "┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻"; break;
@@ -56,7 +57,7 @@
}
String str = linestart+"ID: **"+guild.getId()+"**\n"
+linestart+"Owner: "+FormatUtil.formatUser(guild.getOwner().getUser())+"\n"
- +linestart+"Location: **"+guild.getRegion().getName()+"**\n"
+ +linestart+"Location: "+OtherUtil.regionToFlag(guild.getRegion())+" **"+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"
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 c119988..753bbc6 100644
--- a/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/general/UserinfoCmd.java
@@ -38,6 +38,7 @@
public class UserinfoCmd extends Command
{
private final String linestart = "\u25AB";
+
public UserinfoCmd()
{
this.name = "userinfo";
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 f64a8d7..11d96de 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/BanCmd.java
@@ -37,8 +37,8 @@
super(vortex, Permission.BAN_MEMBERS);
this.name = "ban";
this.aliases = new String[]{"hackban","forceban"};
- this.arguments = "<@users...> [time] [reason]";
- this.help = "bans all provided users";
+ this.arguments = "<@users> [time] [reason]";
+ this.help = "bans users";
this.botPermissions = new Permission[]{Permission.BAN_MEMBERS};
this.guildOnly = true;
}
@@ -85,6 +85,7 @@
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(">");
+ builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully banned <@").append(id).append(">").append(time);
if(minutes>0)
vortex.getDatabase().tempbans.setBan(event.getGuild(), uid, unbanTime);
if(last)
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 e7e5d8a..a641f2a 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/CleanCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/CleanCmd.java
@@ -64,7 +64,7 @@
super(vortex, Permission.MESSAGE_MANAGE, Permission.MESSAGE_HISTORY);
this.name = "clean";
this.arguments = "";
- this.help = "cleans messages matching the given filters";
+ this.help = "cleans messages matching filters";
this.botPermissions = new Permission[]{Permission.MESSAGE_MANAGE, Permission.MESSAGE_HISTORY};
this.guildOnly = true;
}
@@ -167,6 +167,8 @@
week2 = true;
break;
}
+ if(msg.isPinned())
+ continue;
if(all || ids.contains(msg.getAuthor().getId()) || (bots && msg.getAuthor().isBot()) || (embeds && !msg.getEmbeds().isEmpty())
|| (links && LINK_PATTERN.matcher(msg.getContentRaw()).find()) || (images && hasImage(msg)))
{
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/KickCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/KickCmd.java
index 2c28bad..5a958f1 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/KickCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/KickCmd.java
@@ -36,8 +36,8 @@
{
super(vortex, Permission.KICK_MEMBERS);
this.name = "kick";
- this.arguments = "<@users...> [reason]";
- this.help = "kicks all provided users";
+ this.arguments = "<@users> [reason]";
+ this.help = "kicks users";
this.botPermissions = new Permission[]{Permission.KICK_MEMBERS};
this.guildOnly = true;
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/ModcheckCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/ModcheckCmd.java
new file mode 100644
index 0000000..177ccf0
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/ModcheckCmd.java
@@ -0,0 +1,56 @@
+/*
+ * 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.moderation;
+
+import com.jagrosh.jdautilities.command.CommandEvent;
+import com.jagrosh.jdautilities.commons.utils.FinderUtil;
+import com.jagrosh.vortex.Vortex;
+import com.jagrosh.vortex.commands.ModCommand;
+import java.util.List;
+import net.dv8tion.jda.core.Permission;
+import net.dv8tion.jda.core.entities.Member;
+
+/**
+ *
+ * @author John Grosh (john.a.grosh@gmail.com)
+ */
+public class ModcheckCmd extends ModCommand
+{
+ public ModcheckCmd(Vortex vortex)
+ {
+ super(vortex, Permission.BAN_MEMBERS);
+ this.name = "modcheck";
+ this.arguments = "";
+ this.help = "checks a user";
+ this.guildOnly = true;
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ if(event.getArgs().isEmpty() || event.getArgs().equalsIgnoreCase("help"))
+ {
+
+ return;
+ }
+ List members = FinderUtil.findMembers(event.getArgs(), event.getGuild());
+ if(members.size()>1)
+ {
+ //event.replyWarning(FormatUtil.);
+ return;
+ }
+ }
+}
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java
index 2903213..980b8ae 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/MuteCmd.java
@@ -39,8 +39,8 @@
{
super(vortex, Permission.MANAGE_ROLES);
this.name = "mute";
- this.arguments = "<@users...> [time] [reason]";
- this.help = "applies a muted role to provided users";
+ this.arguments = "<@users> [time] [reason]";
+ this.help = "applies muted role to users";
this.botPermissions = new Permission[]{Permission.MANAGE_ROLES};
this.guildOnly = true;
}
@@ -109,13 +109,14 @@
event.reactSuccess();
Instant unmuteTime = 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 muted ").append(FormatUtil.formatUser(m.getUser()));
+ builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully muted ").append(FormatUtil.formatUser(m.getUser())).append(time);
if(minutes>0)
vortex.getDatabase().tempmutes.overrideMute(event.getGuild(), m.getUser().getIdLong(), unmuteTime);
else
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/PardonCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/PardonCmd.java
index 9273542..9512f9e 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/PardonCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/PardonCmd.java
@@ -33,7 +33,7 @@
{
super(vortex, Permission.BAN_MEMBERS);
this.name = "pardon";
- this.arguments = "[numstrikes] <@users...> ";
+ this.arguments = "[numstrikes] <@users> ";
this.help = "removes strikes from users";
this.guildOnly = true;
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/RaidCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/RaidCmd.java
index 3d40875..ff46e75 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/RaidCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/RaidCmd.java
@@ -33,7 +33,7 @@
this.name = "raidmode";
this.aliases = new String[]{"raid","antiraidmode"};
this.arguments = "[ON|OFF] [reason]";
- this.help = "views, enables, or disabled raidmode";
+ this.help = "view, enable, or disable raidmode";
this.botPermissions = new Permission[]{Permission.MANAGE_SERVER, Permission.KICK_MEMBERS};
}
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 fc0063c..2c6ee06 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/ReasonCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/ReasonCmd.java
@@ -30,7 +30,7 @@
{
super(vortex, Permission.BAN_MEMBERS);
this.name = "reason";
- this.help = "updates a reason in the mod log";
+ this.help = "updates a modlog reason";
this.arguments = "[case] ";
this.guildOnly = true;
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java
index 3dd88df..ffae44d 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java
@@ -37,8 +37,8 @@
{
super(vortex, Permission.BAN_MEMBERS);
this.name = "softban";
- this.arguments = "<@users...> [reason]";
- this.help = "bans and unbans all provided users";
+ this.arguments = "<@users> [reason]";
+ this.help = "bans and unbans users";
this.botPermissions = new Permission[]{Permission.BAN_MEMBERS};
this.guildOnly = true;
}
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 ffeeffe..c69bb25 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/StrikeCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/StrikeCmd.java
@@ -21,7 +21,10 @@
import com.jagrosh.vortex.utils.ArgsUtil;
import com.jagrosh.vortex.utils.ArgsUtil.ResolvedArgs;
import com.jagrosh.vortex.utils.FormatUtil;
+import java.util.LinkedList;
+import java.util.List;
import net.dv8tion.jda.core.Permission;
+import net.dv8tion.jda.core.entities.User;
/**
*
@@ -33,7 +36,7 @@
{
super(vortex, Permission.BAN_MEMBERS);
this.name = "strike";
- this.arguments = "[number] <@users...> ";
+ this.arguments = "[number] <@users> ";
this.help = "applies strikes to users";
this.guildOnly = true;
}
@@ -78,29 +81,56 @@
builder.append("\n").append(event.getClient().getError()).append(" You do not have permission to interact with ").append(FormatUtil.formatUser(m.getUser()));
else if(!event.getSelfMember().canInteract(m))
builder.append("\n").append(event.getClient().getError()).append(" I am unable to interact with ").append(FormatUtil.formatUser(m.getUser()));
- else if(m.getUser().isBot())
- builder.append("\n").append(event.getClient().getError()).append(" Strikes cannot be given to bots (").append(FormatUtil.formatFullUser(m.getUser())).append(")");
else
- args.ids.add(m.getUser().getIdLong());
+ args.users.add(m.getUser());
});
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 ->
+ List unknownIds = new LinkedList<>();
+ args.ids.forEach(id ->
{
- if(u.isBot())
- builder.append("\n").append(event.getClient().getError()).append(" Strikes cannot be given to bots (").append(FormatUtil.formatFullUser(u)).append(")");
+ User u = vortex.getShardManager().getUserById(id);
+ if(u==null)
+ unknownIds.add(id);
else
- args.ids.add(u.getIdLong());
+ args.users.add(u);
});
int fnumstrikes = numstrikes;
- args.ids.forEach(id ->
+ if(unknownIds.isEmpty())
+ strikeAll(args.users, numstrikes, args.reason, builder, event);
+ else
+ event.async(() ->
+ {
+ unknownIds.forEach((id) ->
+ {
+ try
+ {
+ args.users.add(event.getJDA().retrieveUserById(id).complete());
+ }
+ catch(Exception ex)
+ {
+ builder.append("\n").append(event.getClient().getError()).append(" `").append(id).append("` is not a valid user ID.");
+ }
+ });
+ strikeAll(args.users, fnumstrikes, args.reason, builder, event);
+ });
+ }
+
+ private void strikeAll(List users, int numstrikes, String reason, StringBuilder builder, CommandEvent event)
+ {
+ users.forEach(u ->
{
- vortex.getStrikeHandler().applyStrikes(event.getMember(), event.getMessage().getCreationTime(), id, fnumstrikes, args.reason);
- builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully gave `").append(fnumstrikes)
- .append("` strikes to ").append(event.getJDA().getUserById(id)==null ? "<@"+id+">" : FormatUtil.formatUser(event.getJDA().getUserById(id)));
+ if(u.isBot())
+ builder.append("\n").append(event.getClient().getError()).append(" Strikes cannot be given to bots (").append(FormatUtil.formatFullUser(u)).append(")");
+ else
+ {
+ vortex.getStrikeHandler().applyStrikes(event.getMember(), event.getMessage().getCreationTime(), u, numstrikes, reason);
+ builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully gave `").append(numstrikes)
+ .append("` strikes to ").append(FormatUtil.formatUser(u));
+ }
});
event.reply(builder.toString());
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/UnmuteCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/UnmuteCmd.java
index 2b80282..7e6ecbb 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/UnmuteCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/UnmuteCmd.java
@@ -37,8 +37,8 @@
{
super(vortex, Permission.MANAGE_ROLES);
this.name = "unmute";
- this.arguments = "<@users...> [reason]";
- this.help = "removes a muted role from provided users";
+ this.arguments = "<@users> [reason]";
+ this.help = "removes muted role from users";
this.botPermissions = new Permission[]{Permission.MANAGE_ROLES};
this.guildOnly = true;
}
diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java
index f0e0a38..b831d23 100644
--- a/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java
@@ -45,7 +45,7 @@
event.getChannel().sendMessage(new MessageBuilder()
.append("**"+event.getSelfUser().getName()+"** settings on **"+event.getGuild().getName()+"**:")
.setEmbed(new EmbedBuilder()
- .setThumbnail(event.getGuild().getIconId()==null ? event.getSelfUser().getEffectiveAvatarUrl() : event.getGuild().getIconUrl())
+ //.setThumbnail(event.getGuild().getIconId()==null ? event.getSelfUser().getEffectiveAvatarUrl() : event.getGuild().getIconUrl())
.addField(vortex.getDatabase().settings.getSettingsDisplay(event.getGuild()))
.addField(vortex.getDatabase().actions.getAllPunishmentsDisplay(event.getGuild()))
.addField(vortex.getDatabase().automod.getSettingsDisplay(event.getGuild()))
diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java
index d493214..d620fb4 100644
--- a/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java
@@ -56,9 +56,9 @@
this.buttons = new ButtonMenu.Builder()
.setText(Constants.SUCCESS+" **Please select a setup option**:\n\n"
+MUTE+" 'Muted' Role\n"
- +AUTOMOD+" Automod\n"
+ //+AUTOMOD+" Automod\n"
+CANCEL+" Cancel")
- .setChoices(MUTE,AUTOMOD,CANCEL)
+ .setChoices(MUTE,CANCEL)
.setEventWaiter(vortex.getEventWaiter())
.setTimeout(1, TimeUnit.MINUTES)
.setFinalAction(m -> m.delete().queue())
diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/TimezoneCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/TimezoneCmd.java
index 3d0e48d..311d50f 100644
--- a/src/main/java/com/jagrosh/vortex/commands/settings/TimezoneCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/settings/TimezoneCmd.java
@@ -46,7 +46,7 @@
{
if(event.getArgs().isEmpty())
{
- event.replyError("Please include a time zone. A full list of timezones can be found here: <"+Constants.WIKI.LOG_TIMEZONE+">");
+ event.replyError("Please include a time zone. A full list of timezones can be found here: <"+Constants.Wiki.LOG_TIMEZONE+">");
return;
}
@@ -65,7 +65,7 @@
}
catch(Exception ex)
{
- event.replyError("`"+event.getArgs()+"` is not a valid timezone! See <"+Constants.WIKI.LOG_TIMEZONE+"> for a full list.");
+ event.replyError("`"+event.getArgs()+"` is not a valid timezone! See <"+Constants.Wiki.LOG_TIMEZONE+"> for a full list.");
}
}
}
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 a267256..4f723c7 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java
@@ -40,6 +40,7 @@
public final static SQLColumn MAX_MENTIONS = new IntegerColumn("MAX_MENTIONS", false, 0);
public final static SQLColumn MAX_ROLE_MENTIONS = new IntegerColumn("MAX_ROLE_MENTIONS", false, 0);
+ public final static SQLColumn MAX_LINES = new IntegerColumn("MAX_LINES", false, 0);
public final static SQLColumn RAIDMODE_NUMBER = new IntegerColumn("RAIDMODE_NUMBER", false, 0);
public final static SQLColumn RAIDMODE_TIME = new IntegerColumn("RAIDMODE_TIME", false, 0);
@@ -78,14 +79,17 @@
? "Disabled\n\n"
: "Strikes: **" + settings.inviteStrikes + "**\n\n")
+ "__Anti-Duplicate__\n" + (settings.useAntiDuplicate()
- ? "Delete Threshold: **" + settings.dupeDeleteThresh + "**\n" +
- "Strike Threshold: **" + settings.dupeStrikeThresh + "**\n" +
+ ? "Strike Threshold: **" + settings.dupeStrikeThresh + "**\n" +
+ "Delete Threshold: **" + settings.dupeDeleteThresh + "**\n" +
"Strikes: **" + settings.dupeStrikes + "**\n\n"
: "Disabled\n\n")
- + "__Anti-Mass-Mention__\n" + (settings.maxMentions==0 && settings.maxRoleMentions==0
+ + "__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
+ ? "Disabled\n\n"
+ : "Max Lines / Message: **"+settings.maxLines+"**\n\n")
+ "__Auto Anti-Raid Mode__\n" + (settings.useAutoRaidMode()
? "**" + settings.raidmodeNumber + "** joins / **" + settings.raidmodeTime + "** seconds\n"
: "Disabled\n")
@@ -147,6 +151,26 @@
});
}
+ public void setMaxLines(Guild guild, int max)
+ {
+ invalidateCache(guild);
+ readWrite(selectAll(GUILD_ID.is(guild.getIdLong())), rs ->
+ {
+ if(rs.next())
+ {
+ MAX_LINES.updateValue(rs, max);
+ rs.updateRow();
+ }
+ else
+ {
+ rs.moveToInsertRow();
+ GUILD_ID.updateValue(rs, guild.getIdLong());
+ MAX_LINES.updateValue(rs, max);
+ rs.insertRow();
+ }
+ });
+ }
+
public void setAutoRaidMode(Guild guild, int number, int time)
{
invalidateCache(guild);
@@ -241,6 +265,7 @@
public class AutomodSettings
{
public final int maxMentions, maxRoleMentions;
+ public final int maxLines;
public final int raidmodeNumber, raidmodeTime;
public final int inviteStrikes;
public final int refStrikes;
@@ -250,6 +275,7 @@
{
this.maxMentions = 0;
this.maxRoleMentions = 0;
+ this.maxLines = 0;
this.raidmodeNumber = 0;
this.raidmodeTime = 0;
this.inviteStrikes = 0;
@@ -259,11 +285,12 @@
this.dupeStrikeThresh = 0;
}
- private AutomodSettings(int maxMentions, int maxRoleMentions, int raidmodeNumber, int raidmodeTime,
+ private AutomodSettings(int maxMentions, int maxRoleMentions, int maxNewlines, int raidmodeNumber, int raidmodeTime,
int inviteStrikes, int refStrikes, int dupeStrikes, int dupeDeleteThresh, int dupeStrikeThresh)
{
this.maxMentions = maxMentions;
this.maxRoleMentions = maxRoleMentions;
+ this.maxLines = maxNewlines;
this.raidmodeNumber = raidmodeNumber;
this.raidmodeTime = raidmodeTime;
this.inviteStrikes = inviteStrikes;
@@ -275,7 +302,7 @@
private AutomodSettings(ResultSet rs) throws SQLException
{
- this(MAX_MENTIONS.getValue(rs), MAX_ROLE_MENTIONS.getValue(rs), RAIDMODE_NUMBER.getValue(rs), RAIDMODE_TIME.getValue(rs),
+ this(MAX_MENTIONS.getValue(rs), MAX_ROLE_MENTIONS.getValue(rs), MAX_LINES.getValue(rs), RAIDMODE_NUMBER.getValue(rs), RAIDMODE_TIME.getValue(rs),
INVITE_STRIKES.getValue(rs), REF_STRIKES.getValue(rs), DUPE_STRIKES.getValue(rs), DUPE_DELETE_THRESH.getValue(rs),
DUPE_STRIKE_THRESH.getValue(rs));
}
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 0bd9a6c..f3fa231 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java
@@ -19,8 +19,7 @@
import com.jagrosh.easysql.DatabaseConnector;
import com.jagrosh.easysql.SQLColumn;
import com.jagrosh.easysql.columns.*;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import com.jagrosh.vortex.automod.Filter;
import java.util.List;
import net.dv8tion.jda.core.entities.Guild;
@@ -61,18 +60,6 @@
return null;
}
- public class Filter
- {
- public final String value;
- public final Type type;
-
- private Filter(ResultSet rs) throws SQLException
- {
- this.value = VALUE.getValue(rs);
- this.type = Type.values()[TYPE.getValue(rs)];
- }
- }
-
public enum Type
{
WORD, GLOB, REGEX
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 c963d58..61573f9 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java
@@ -41,7 +41,7 @@
private static final String STRIKES_TITLE = Action.STRIKE.getEmoji()+" Punishments";
- public static final String DEFAULT_SETUP_MESSAGE = "\n" + Constants.WARNING + "It looks like you've set up some automoderation without assigning any punishments! "
+ public static final String DEFAULT_SETUP_MESSAGE = "\n" + Constants.WARNING + " It looks like you've set up some automoderation without assigning any punishments! "
+ "I've gone ahead and set up some default punishments; you can see the settings with `" + Constants.PREFIX
+ "settings` and set or change any punishments with the `" + Constants.PREFIX+"setstrikes` command!";
private static final int[] DEFAULT_STRIKE_COUNTS = {2, 3, 4, 5, 6, 7};
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 bc00962..9ab516d 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java
@@ -43,11 +43,6 @@
return GUILD_ID+", "+USER_ID;
}
- public int[] addStrikes(Member target, int strikes)
- {
- return addStrikes(target.getGuild(), target.getUser().getIdLong(), strikes);
- }
-
public int[] addStrikes(Guild guild, long targetId, int strikes)
{
return readWrite(selectAll(GUILD_ID.is(guild.getId())+" AND "+USER_ID.is(targetId)), rs ->
@@ -71,7 +66,7 @@
});
}
- public int[] setStrikes(Member target, int strikes)
+ /*public int[] setStrikes(Member target, int strikes)
{
return setStrikes(target.getGuild(), target.getUser().getIdLong(), strikes);
}
@@ -97,7 +92,7 @@
return new int[]{0, strikes<0 ? 0 : strikes};
}
});
- }
+ }//*/
public int[] removeStrikes(Member target, int strikes)
{
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 18745f4..15f09e0 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java
@@ -98,6 +98,15 @@
});
}
+ public void removeMute(Guild guild, long userId)
+ {
+ readWrite(selectAll(GUILD_ID.is(guild.getId())+" AND "+USER_ID.is(userId)), rs ->
+ {
+ if(rs.next())
+ rs.deleteRow();
+ });
+ }
+
public void checkUnmutes(Guild guild)
{
if(!guild.isAvailable())
diff --git a/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java b/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java
index 26002b6..1209161 100644
--- a/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java
+++ b/src/main/java/com/jagrosh/vortex/logging/BasicLogger.java
@@ -73,6 +73,8 @@
TextChannel tc = vortex.getDatabase().settings.getSettings(newMessage.getGuild()).getMessageLogChannel(newMessage.getGuild());
if(tc==null)
return;
+ if(newMessage.getContentRaw().equals(oldMessage.getContentRaw()))
+ return;
EmbedBuilder edit = new EmbedBuilder()
.setColor(Color.YELLOW)
.appendDescription("**From:** ")
@@ -83,7 +85,7 @@
else
edit.appendDescription("\n**To:** "+newm);
log(newMessage.getEditedTime()==null ? newMessage.getCreationTime() : newMessage.getEditedTime(), tc, "\u26A0",
- FormatUtil.formatUser(newMessage.getAuthor())+" edited a message in "+newMessage.getTextChannel().getAsMention()+":", edit.build());
+ FormatUtil.formatFullUser(newMessage.getAuthor())+" edited a message in "+newMessage.getTextChannel().getAsMention()+":", edit.build());
}
public void logMessageDelete(Message oldMessage)
@@ -100,7 +102,7 @@
.setColor(Color.RED)
.appendDescription(formatted);
log(OffsetDateTime.now(), tc, "\u274C",
- FormatUtil.formatUser(oldMessage.getAuthor())+"'s message has been deleted from "+oldMessage.getTextChannel().getAsMention()+":", delete.build());
+ FormatUtil.formatFullUser(oldMessage.getAuthor())+"'s message has been deleted from "+oldMessage.getTextChannel().getAsMention()+":", delete.build());
}
public void logMessageBulkDelete(List messages, int count, TextChannel text)
diff --git a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java
index 967d3cb..249fb94 100644
--- a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java
+++ b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java
@@ -269,6 +269,11 @@
.replaceFirst(Action.BAN.getVerb(), Action.SOFTBAN.getVerb())).queue();
return;
}
+ vortex.getDatabase().tempbans.clearBan(guild, ale.getTargetIdLong());
+ }
+ if(act==Action.UNMUTE)
+ {
+ vortex.getDatabase().tempmutes.removeMute(guild, ale.getTargetIdLong());
}
modlog.sendMessage(FormatUtil.filterEveryone(minutes > 0 ?
LogUtil.modlogTimeFormat(ale.getCreationTime(), timezone, getCaseNumber(modlog), mod, act, minutes, target, reason) :
@@ -327,7 +332,7 @@
if(num!=-1)
{
caseNum.put(tc.getGuild().getIdLong(), num+2);
- result.accept(num);
+ result.accept(num+1);
return;
}
}
diff --git a/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java b/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java
index b51cfbe..a0a8fa3 100644
--- a/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/ArgsUtil.java
@@ -79,12 +79,15 @@
else
users.add(user);
found = true;
- args = args.substring(mat.group().length()).trim();
break;
}
}
+ args = args.substring(mat.group().length()).trim();
if(found)
continue;
+ unresolved.add(mat.group());
+ found = true;
+ continue;
}
mat = ID.matcher(args);
if(mat.find())
diff --git a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
index 3c1cc24..1d63b1f 100644
--- a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
@@ -27,7 +27,6 @@
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.MessageBuilder;
import net.dv8tion.jda.core.entities.Message;
-import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.entities.TextChannel;
/**
@@ -47,7 +46,7 @@
{
StringBuilder sb = new StringBuilder(m.getContentRaw());
m.getAttachments().forEach(att -> sb.append("\n").append(att.getUrl()));
- return sb.toString();
+ return sb.length()>2048 ? sb.toString().substring(0, 2040) : sb.toString();
}
public static String formatUser(User user)
@@ -214,17 +213,19 @@
category = command.getCategory();
}
}
- sb.append("```fix\n").append(event.getClient().getTextualPrefix()).append(event.getClient().getPrefix()==null?" ":"").append(command.getName())
- .append(command.getArguments()==null ? "" : " "+command.getArguments()+"")
- .append(" = ").append(command.getHelp()).append("```");
+ sb.append("[`").append(event.getClient().getTextualPrefix()).append(event.getClient().getPrefix()==null?" ":"").append(command.getName())
+ .append(command.getArguments()==null ? "" : " "+command.getArguments()+"").append("`](")
+ .append(Constants.Wiki.Shortened.fromCategory(command.getCategory())).append(") - ").append(command.getHelp()).append("\n");
}
}
builder.addField(category==null ? "General Commands" : category.getName()+" Commands", sb.toString()+"\u200B", true);
- builder.addField("Additional Help", "["+event.getSelfUser().getName()+" Wiki]("+Constants.WIKI.WIKI_BASE+")\n"
- + "[Support Server]("+event.getClient().getServerInvite()+")\n"
- + "[Full Command Reference]("+Constants.WIKI.FULL_COMMAND_REFERENCE+")", 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);
return new MessageBuilder().append(Constants.SUCCESS+" **"+event.getSelfUser().getName()+"** Commands:").setEmbed(builder.build()).build();
}
+
}
diff --git a/src/main/java/com/jagrosh/vortex/utils/LogUtil.java b/src/main/java/com/jagrosh/vortex/utils/LogUtil.java
index f2df0f3..79d83ba 100644
--- a/src/main/java/com/jagrosh/vortex/utils/LogUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/LogUtil.java
@@ -139,9 +139,9 @@
private final static Pattern AUDIT_TIMED_PATTERN = Pattern.compile("^(\\S.{0,32}\\S)#(\\d{4}) \\((\\d{1,9})m\\): (.*)$");
// Auditlog methods
- public static String auditStrikeReasonFormat(Member moderator, int minutes, int strikes, String reason)
+ public static String auditStrikeReasonFormat(Member moderator, int minutes, int oldstrikes, int newstrikes, String reason)
{
- return auditReasonFormat(moderator, minutes, "["+strikes+" strikes] "+reason);
+ return auditReasonFormat(moderator, minutes, "["+oldstrikes+" → "+newstrikes+" strikes] "+reason);
}
public static String auditReasonFormat(Member moderator, String reason)
diff --git a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java
index 5b6d666..d556599 100644
--- a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java
@@ -15,6 +15,7 @@
*/
package com.jagrosh.vortex.utils;
+import net.dv8tion.jda.core.Region;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Role;
@@ -73,4 +74,40 @@
}
return timeinseconds;
}
+
+ public static String regionToFlag(Region region)
+ {
+ switch(region)
+ {
+ case AMSTERDAM: return "\uD83C\uDDF3\uD83C\uDDF1";
+ case BRAZIL: return "\uD83C\uDDE7\uD83C\uDDF7";
+ case EU_CENTRAL: return "\uD83C\uDDEA\uD83C\uDDFA";
+ case EU_WEST: return "\uD83C\uDDEA\uD83C\uDDFA";
+ case FRANKFURT: return "\uD83C\uDDE9\uD83C\uDDEA";
+ case HONG_KONG: return "\uD83C\uDDED\uD83C\uDDF0";
+ case JAPAN: return "\uD83C\uDDEF\uD83C\uDDF5";
+ case LONDON: return "\uD83C\uDDEC\uD83C\uDDE7";
+ case RUSSIA: return "\uD83C\uDDF7\uD83C\uDDFA";
+ case SINGAPORE: return "\uD83C\uDDF8\uD83C\uDDEC";
+ case SYDNEY: return "\uD83C\uDDE6\uD83C\uDDFA";
+ case US_CENTRAL: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case US_EAST: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case US_SOUTH: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case US_WEST: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case VIP_AMSTERDAM: return "\uD83C\uDDF3\uD83C\uDDF1";
+ case VIP_BRAZIL: return "\uD83C\uDDE7\uD83C\uDDF7";
+ case VIP_EU_CENTRAL: return "\uD83C\uDDEA\uD83C\uDDFA";
+ case VIP_EU_WEST: return "\uD83C\uDDEA\uD83C\uDDFA";
+ case VIP_FRANKFURT: return "\uD83C\uDDE9\uD83C\uDDEA";
+ case VIP_JAPAN: return "\uD83C\uDDEF\uD83C\uDDF5";
+ case VIP_LONDON: return "\uD83C\uDDEC\uD83C\uDDE7";
+ case VIP_SINGAPORE: return "\uD83C\uDDF8\uD83C\uDDEC";
+ case VIP_SYDNEY: return "\uD83C\uDDE6\uD83C\uDDFA";
+ case VIP_US_CENTRAL: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case VIP_US_EAST: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case VIP_US_SOUTH: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case VIP_US_WEST: return "\uD83C\uDDFA\uD83C\uDDF8";
+ case UNKNOWN: default: return "\uD83C\uDFF3";
+ }
+ }
}