Skip to content

Commit

Permalink
Merge branch 'master' into feature/jda4
Browse files Browse the repository at this point in the history
  • Loading branch information
jagrosh committed Jul 22, 2020
2 parents bf71f6c + 7dfaf21 commit 28213bf
Show file tree
Hide file tree
Showing 36 changed files with 418 additions and 131 deletions.
58 changes: 29 additions & 29 deletions lists/copypastas.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// Copypastas
// Bits of text that tend to be copied and pasted
// False Discord PSA
False PSA || out for a Discord && going around && those who accept && send this to as many && if you see this
Fake Hacker PSA || not accept friend request from && hackers && tell everyone && copy && paste
Fake Discord shutdown || discord && clos && populated && active && please send && copy && paste && deleted without hesitation
// Share or else
Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯
Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏
Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ
"Read or you die" || Carry on reading && Once there was && Now every week && send this to && copy and paste
Jake Paul || Jake Paul on a tower about to jump && copy and paste && discord server
"Tag you're it" || funny you opened this because && over the next && first you have && send it to && break the chain
// Unicode
Bob || /▌ && /\ && This is bob
Lennipede || ╚═(███)═╝ && Lenn
Doge || ▐▄█▀▒▒▒▒▄▀█▄ && ▐▄█▄█▌▄▒▀▒ && ▒▀▀▄▄▒▒▒▄▒
// Text
Navy Seals || say about me && ll have you know I && I am trained && Think again && Not only am I extensively trained && kid
Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftly woven && heavily && intellectual capacity && cryptic reference
Shrek || years old && is love && is life && spread && push against && straight in the
// Scams
Fake Libra Site || getlⅰbra.tech
Fake Libra Site (2) || buylⅰbra.τech
// Copypastas
// Bits of text that tend to be copied and pasted

// False Discord PSA
False PSA || out for a Discord && going around && those who accept && send this to as many && if you see this
Fake Hacker PSA || not accept && friend request from && hacker && tell everyone && copy && paste
Fake Discord shutdown || discord && clos && populated && active && please send && copy && paste && deleted without hesitation

// Share or else
Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯
Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏
Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ
Memecat (2) || Λ_Λ && ˇωˇ && > ⌒ヽ
"Read or you die" || Carry on reading && Once there was && Now every week && send this to && copy and paste
Jake Paul || Jake Paul on a tower about to jump && copy and paste && discord server
"Tag you're it" || funny you opened this because && over the next && first you have && send it to && break the chain

// Unicode
Bob || /▌ && /\ && This is bob
Lennipede || ╚═(███)═╝ && Lenn
Doge || ▐▄█▀▒▒▒▒▄▀█▄ && ▐▄█▄█▌▄▒▀▒ && ▒▀▀▄▄▒▒▒▄▒

// Text
Navy Seals || say about me && ll have you know I && I am trained && Think again && Not only am I extensively trained && kid
Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftly woven && heavily && intellectual capacity && cryptic reference
Shrek || years old && is love && is life && spread && push against && straight in the

// Scams
Fake Libra Site || lⅰbra
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.1_110</version>
<version>4.2.0_181</version>
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities</artifactId>
<version>3.0.2</version>
<version>3.0.4</version>
<type>pom</type>
</dependency>
<dependency>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/jagrosh/vortex/Vortex.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@
import com.jagrosh.vortex.utils.OtherUtil;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.exceptions.PermissionException;
import net.dv8tion.jda.api.requests.restaction.MessageAction;
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder;
import net.dv8tion.jda.api.sharding.ShardManager;
import net.dv8tion.jda.api.utils.cache.CacheFlag;
Expand Down Expand Up @@ -162,6 +165,7 @@ public Vortex() throws Exception
new AnnounceCmd(),
new AuditCmd(),
new DehoistCmd(),
new ExportCmd(this),
new InvitepruneCmd(this),
new LookupCmd(this),

Expand All @@ -183,6 +187,7 @@ public Vortex() throws Exception
.setDiscordBotsKey(config.getString("listing.discord-bots"))
//.setCarbonitexKey(config.getString("listing.carbon"))
.build();
MessageAction.setDefaultMentions(Arrays.asList(Message.MentionType.EMOTE, Message.MentionType.CHANNEL));
shards = new DefaultShardManagerBuilder()
.setShardsTotal(config.getInt("shards-total"))
.setToken(config.getString("bot-token"))
Expand All @@ -193,6 +198,7 @@ public Vortex() throws Exception
.setRequestTimeoutRetry(true)
.setDisabledCacheFlags(EnumSet.of(CacheFlag.EMOTE, CacheFlag.ACTIVITY)) //TODO: dont disable GAME
.setSessionController(new BlockingSessionController())

.build();

modlog.start();
Expand Down Expand Up @@ -285,8 +291,10 @@ public void leavePointlessGuilds()
return false;
if(Constants.OWNER_ID.equals(g.getOwnerId()))
return false;
int botcount = (int)g.getMemberCache().stream().filter(m -> m.getUser().isBot()).count();
if(g.getMemberCache().size()-botcount<15 || (botcount>20 && ((double)botcount/g.getMemberCache().size())>0.5))
int botcount = (int) g.getMemberCache().stream().filter(m -> m.getUser().isBot()).count();
int totalcount = (int) g.getMemberCache().size();
int humancount = totalcount - botcount;
if(humancount < 30 || botcount > humancount)
{
if(database.settings.hasSettings(g))
return false;
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/com/jagrosh/vortex/automod/AutoMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
public class AutoMod
{
private static final Pattern INVITES = Pattern.compile("discord\\s?(?:(?:\\.|dot|\\(\\.\\)|\\(dot\\))\\s?gg|app\\s?\\.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})",
private static final Pattern INVITES = Pattern.compile("discord\\s?(?:(?:\\.|dot|\\(\\.\\)|\\(dot\\))\\s?gg|(?:app)?\\s?\\.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})",
Pattern.CASE_INSENSITIVE);

private static final Pattern REF = Pattern.compile("https?:\\/\\/\\S+(?:\\/ref\\/|[?&#]ref(?:errer|erral)?=)\\S+", Pattern.CASE_INSENSITIVE);
Expand Down Expand Up @@ -204,11 +204,11 @@ else if(ams.useAutoRaidMode())
private boolean shouldPerformAutomod(Member member, TextChannel channel)
{
// ignore users not in the guild
if(member==null || member.getGuild()==null)
if(member==null)
return false;

// ignore broken guilds
if(member.getGuild().getSelfMember()==null || member.getGuild().getOwner()==null)
if(member.getGuild().getOwner()==null)
return false;

// ignore bots
Expand Down Expand Up @@ -273,11 +273,9 @@ public void performAutomod(Message message)
return;

// check the channel for channel-specific settings
boolean preventSpam = message.getTextChannel().getTopic()==null
|| !message.getTextChannel().getTopic().toLowerCase().contains("{spam}");
boolean preventInvites = (message.getTextChannel().getTopic()==null
|| !message.getTextChannel().getTopic().toLowerCase().contains("{invites}"))
&& settings.inviteStrikes > 0;
String topic = message.getTextChannel().getTopic();
boolean preventSpam = topic==null || !topic.toLowerCase().contains("{spam}");
boolean preventInvites = (topic==null || !topic.toLowerCase().contains("{invites}")) && settings.inviteStrikes > 0;

List<Long> inviteWhitelist = !preventInvites ? Collections.emptyList()
: vortex.getDatabase().inviteWhitelist.readWhitelist(message.getGuild());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.command.CommandListener;
import com.jagrosh.vortex.utils.FormatUtil;
import com.jagrosh.vortex.utils.Usage;
import net.dv8tion.jda.api.entities.ChannelType;
import org.slf4j.Logger;
Expand All @@ -36,9 +37,9 @@ public class CommandExceptionListener implements CommandListener
public void onCommandException(CommandEvent event, Command command, Throwable throwable)
{
if (throwable instanceof CommandErrorException)
event.replyError(throwable.getMessage());
event.replyError(FormatUtil.filterEveryone(throwable.getMessage()));
else if (throwable instanceof CommandWarningException)
event.replyWarning(throwable.getMessage());
event.replyWarning(FormatUtil.filterEveryone(throwable.getMessage()));
else
log.error("An exception occurred in a command: "+command, throwable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.database.managers.AutomodManager;
import com.jagrosh.vortex.database.managers.PunishmentManager;
import com.jagrosh.vortex.utils.FormatUtil;

/**
*
Expand Down Expand Up @@ -61,7 +62,7 @@ protected void execute(CommandEvent event)
numstrikes = 0;
else
{
event.replyError("`"+event.getArgs()+"` is not a valid integer!");
event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!"));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.database.managers.AutomodManager;
import com.jagrosh.vortex.database.managers.PunishmentManager;
import com.jagrosh.vortex.utils.FormatUtil;

/**
*
Expand Down Expand Up @@ -61,7 +62,7 @@ protected void execute(CommandEvent event)
numstrikes = 0;
else
{
event.replyError("`"+event.getArgs()+"` is not a valid integer!");
event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!"));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.database.managers.AutomodManager;
import com.jagrosh.vortex.database.managers.PunishmentManager;
import com.jagrosh.vortex.utils.FormatUtil;

/**
*
Expand Down Expand Up @@ -62,7 +63,7 @@ protected void execute(CommandEvent event)
numstrikes = 0;
else
{
event.replyError("`"+event.getArgs()+"` is not a valid integer!");
event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!"));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.database.managers.AutomodManager;
import com.jagrosh.vortex.database.managers.PunishmentManager;
import com.jagrosh.vortex.utils.FormatUtil;

/**
*
Expand Down Expand Up @@ -61,7 +62,7 @@ protected void execute(CommandEvent event)
numstrikes = 0;
else
{
event.replyError("`"+event.getArgs()+"` is not a valid integer!");
event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!"));
return;
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.automod.Filter;
import com.jagrosh.vortex.database.managers.PremiumManager;
import com.jagrosh.vortex.utils.FormatUtil;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.MessageEmbed.Field;
Expand Down Expand Up @@ -113,8 +114,8 @@ protected void execute(CommandEvent event)
Filter filter = Filter.parseFilter(parts[0], strikes, parts[2]);
if(vortex.getDatabase().filters.addFilter(event.getGuild(), filter))
{
event.replySuccess("Filter *" + filter.name + "* (`" + filter.strikes + " " + Action.STRIKE.getEmoji()
+ "`) successfully created with filtered terms:\n" + filter.printContentEscaped());
event.replySuccess(FormatUtil.filterEveryone("Filter *" + filter.name + "* (`" + filter.strikes + " " + Action.STRIKE.getEmoji()
+ "`) successfully created with filtered terms:\n" + filter.printContentEscaped()));
}
else
{
Expand Down Expand Up @@ -153,11 +154,11 @@ protected void execute(CommandEvent event)
Filter filter = vortex.getDatabase().filters.deleteFilter(event.getGuild(), event.getArgs());
if(filter == null)
{
event.replyError("Filter `" + event.getArgs() + "` could not be found");
event.replyError(FormatUtil.filterEveryone("Filter `" + event.getArgs() + "` could not be found"));
}
else
{
event.replySuccess("Removed filter `" + filter.name + "`");
event.replySuccess(FormatUtil.filterEveryone("Removed filter `" + filter.name + "`"));
}
}
}
Expand All @@ -181,7 +182,7 @@ protected void execute(CommandEvent event)
Field field = vortex.getDatabase().filters.getFiltersDisplay(event.getGuild());
if(field == null)
{
event.replyWarning("There are no filters for **" + event.getGuild().getName() + "**");
event.replyWarning(FormatUtil.filterEveryone("There are no filters for **" + event.getGuild().getName() + "**"));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ else if(r.getPermissions().contains(Permission.ADMINISTRATOR)

List<Role> roles = FinderUtil.findRoles(event.getArgs(), event.getGuild());
if(roles.isEmpty())
event.replyError("No roles or text channels found for `"+event.getArgs()+"`");
event.replyError(FormatUtil.filterEveryone("No roles or text channels found for `"+event.getArgs()+"`"));
else if (roles.size()==1)
{
vortex.getDatabase().ignores.ignore(roles.get(0));
event.replySuccess("Automod is now ignoring role `"+roles.get(0).getName()+"`");
event.replySuccess(FormatUtil.filterEveryone("Automod is now ignoring role `"+roles.get(0).getName()+"`"));
}
else
event.replyWarning(FormatUtil.listOfRoles(roles, event.getArgs()));
event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfRoles(roles, event.getArgs())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.dv8tion.jda.api.Permission;
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.database.managers.PunishmentManager;
import com.jagrosh.vortex.utils.FormatUtil;

/**
*
Expand Down Expand Up @@ -60,7 +61,7 @@ protected void execute(CommandEvent event)
maxlines = 0;
else
{
event.replyError("`"+event.getArgs()+"` is not a valid integer!");
event.replyError(FormatUtil.filterEveryone("`"+event.getArgs()+"` is not a valid integer!"));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.vortex.Constants;
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.database.managers.PremiumManager;
import net.dv8tion.jda.api.Permission;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ protected void execute(CommandEvent event) {

List<Role> roles = FinderUtil.findRoles(event.getArgs(), event.getGuild());
if(roles.isEmpty())
event.replyError("No roles or text channels found for `"+event.getArgs()+"`");
event.replyError(FormatUtil.filterEveryone("No roles or text channels found for `"+event.getArgs()+"`"));
else if (roles.size()==1)
{
if(vortex.getDatabase().ignores.unignore(roles.get(0)))
event.replySuccess("Automod is no longer ignoring role `"+roles.get(0).getName()+"`");
else
event.replyError("Automod was not ignoring role `"+roles.get(0).getName()+"`"
event.replyError(FormatUtil.filterEveryone("Automod was not ignoring role `"+roles.get(0).getName()+"`"
+ "\n"+event.getClient().getWarning()+" If this role is still listed when using `"+event.getClient().getPrefix()+"ignore`:"
+ "\n`[can't interact]` - the role is above "+event.getSelfUser().getName()+"'s highest role; try moving the '"+event.getSelfUser().getName()+"' role higher"
+ "\n`[elevated perms]` - the role has one of the following permissions: Kick Members, Ban Members, Manage Server, Manage Messages, Administrator");
+ "\n`[elevated perms]` - the role has one of the following permissions: Kick Members, Ban Members, Manage Server, Manage Messages, Administrator"));
}
else
event.replyWarning(FormatUtil.listOfRoles(roles, event.getArgs()));
event.replyWarning(FormatUtil.filterEveryone(FormatUtil.listOfRoles(roles, event.getArgs())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.utils.FormatUtil;
import net.dv8tion.jda.api.Permission;

import java.util.ArrayList;
Expand Down Expand Up @@ -74,8 +75,8 @@ private void handleShow(CommandEvent event, String[] args)
return;
}
List<Long> currentWL = vortex.getDatabase().inviteWhitelist.readWhitelist(event.getGuild());
event.replySuccess("Whitelisted Guild IDs:\n" + (currentWL.isEmpty() ? "None" :
"`" + currentWL.stream().map(String::valueOf).collect(Collectors.joining("`, `")) + "`"));
event.replySuccess(FormatUtil.filterEveryone("Whitelisted Guild IDs:\n" + (currentWL.isEmpty() ? "None" :
"`" + currentWL.stream().map(String::valueOf).collect(Collectors.joining("`, `")) + "`")));
}

private void handleAdd(CommandEvent event, String[] args)
Expand Down
Loading

0 comments on commit 28213bf

Please sign in to comment.