diff --git a/pom.xml b/pom.xml
index 7576005..dbc0911 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,12 +24,12 @@
net.dv8tion
JDA
- 3.6.0_355
+ 3.6.0_358
com.jagrosh
jda-utilities
- 2.1
+ 2.1.1
pom
@@ -43,4 +43,33 @@
1.2.3
+
+
+
+
+ maven-assembly-plugin
+
+
+
+ com.jagrosh.vortex.Vortex
+ true
+ true
+
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/jagrosh/vortex/Constants.java b/src/main/java/com/jagrosh/vortex/Constants.java
index e05a6d4..0b001b4 100644
--- a/src/main/java/com/jagrosh/vortex/Constants.java
+++ b/src/main/java/com/jagrosh/vortex/Constants.java
@@ -25,7 +25,7 @@
public class Constants
{
public final static OffsetDateTime STARTUP = OffsetDateTime.now();
- public final static String PREFIX = "))";
+ public final static String PREFIX = ">>";
public final static String SUCCESS = "<:vSuccess:390202497827864597>";
public final static String WARNING = "<:vWarning:390208158699618306>";
public final static String ERROR = "<:vError:390229421228949504>";
@@ -38,11 +38,11 @@
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=169463754382114816&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";
- public final static String NEED_PRO = WARNING + " Sorry, this feature requires Vortex Pro. Vortex Pro is not currently available.";
+ public final static String NEED_PRO = WARNING + " Sorry, this feature requires Vortex Pro. Vortex Pro is not available yet.";
public final static class Wiki
{
diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java
index 9cdbea1..946b089 100644
--- a/src/main/java/com/jagrosh/vortex/Vortex.java
+++ b/src/main/java/com/jagrosh/vortex/Vortex.java
@@ -81,6 +81,7 @@
* 6 - database password
* 7 - log webhook url
* 8 - category id
+ * 9 - number of shards
*/
List tokens = Files.readAllLines(Paths.get("config.txt"));
waiter = new EventWaiter();
@@ -96,7 +97,7 @@
CommandClient client = new CommandClientBuilder()
.setPrefix(Constants.PREFIX)
- .setGame(Game.watching("Type "+Constants.PREFIX+"help | Vortex 2.0 Beta"))
+ .setGame(Game.watching("Type "+Constants.PREFIX+"help"))
.setOwnerId(Constants.OWNER_ID)
.setServerInvite(Constants.SERVER_INVITE)
.setEmojis(Constants.SUCCESS, Constants.WARNING, Constants.ERROR)
@@ -162,7 +163,8 @@
// Owner
new EvalCmd(this),
new DebugCmd(this),
- new ReloadCmd(this)
+ new ReloadCmd(this),
+ new TransferCmd(this)
)
.setHelpConsumer(event -> event.replyInDm(FormatUtil.formatHelp(event, this), m ->
{
@@ -177,7 +179,7 @@
//.setDiscordBotListKey(tokens.get(3))
.build();
shards = new DefaultShardManagerBuilder()
- .setShardsTotal(2)
+ .setShardsTotal(Integer.parseInt(tokens.get(9)))
.setToken(tokens.get(0))
.addEventListeners(new Listener(this), client, waiter)
.setStatus(OnlineStatus.DO_NOT_DISTURB)
diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
index 4bcbb64..292a2e3 100644
--- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
+++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java
@@ -60,9 +60,9 @@
private static final Logger LOG = LoggerFactory.getLogger("AutoMod");
public static final String RESTORE_MUTE_ROLE_AUDIT = "Restoring Muted Role";
- public static final Character[] VALID_DEHOIST_CHAR = {'!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/'};
+ public static final char[] VALID_DEHOIST_CHAR = {'!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/'};
public static final String DEHOIST_PREFIX = "\uD82F\uDCA2";
- public static final String DEHOIST_JOINED = "`"+FormatUtil.join("`, `", (Character c) -> Character.toString(c), VALID_DEHOIST_CHAR)+"`";
+ public static final String DEHOIST_JOINED = "`"+FormatUtil.join("`, `", VALID_DEHOIST_CHAR)+"`";
private final Vortex vortex;
diff --git a/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java b/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java
index 85ffdc2..63a097b 100644
--- a/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java
+++ b/src/main/java/com/jagrosh/vortex/commands/CommandExceptionListener.java
@@ -18,6 +18,8 @@
import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.command.CommandListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -25,6 +27,8 @@
*/
public class CommandExceptionListener implements CommandListener
{
+ private final Logger log = LoggerFactory.getLogger("Command");
+
@Override
public void onCommandException(CommandEvent event, Command command, Throwable throwable)
{
@@ -33,7 +37,7 @@
else if (throwable instanceof CommandWarningException)
event.replyWarning(throwable.getMessage());
else
- throwable.printStackTrace();
+ log.error("An exception occurred in a command: "+command, throwable);
}
public static class CommandErrorException extends RuntimeException
diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/VoicekickCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/VoicekickCmd.java
index d08c3bf..1c31ad3 100644
--- a/src/main/java/com/jagrosh/vortex/commands/moderation/VoicekickCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/moderation/VoicekickCmd.java
@@ -18,6 +18,7 @@
import java.util.LinkedList;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.vortex.Vortex;
+import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException;
import com.jagrosh.vortex.commands.ModCommand;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Member;
@@ -40,13 +41,15 @@
this.aliases = new String[]{"vckick"};
this.arguments = "<@users> [reason]";
this.help = "removes users from voice channels";
- this.botPermissions = new Permission[]{Permission.VOICE_MOVE_OTHERS, Permission.MANAGE_CHANNEL, Permission.VOICE_CONNECT};
+ this.botPermissions = new Permission[]{Permission.MANAGE_CHANNEL};
this.guildOnly = true;
}
@Override
protected void execute(CommandEvent event)
{
+ if(!event.getSelfMember().hasPermission(Permission.VOICE_MOVE_OTHERS, Permission.VOICE_CONNECT))
+ throw new CommandErrorException("I need permission to connect to voice channels and move members to do that!");
ArgsUtil.ResolvedArgs args = ArgsUtil.resolve(event.getArgs(), event.getGuild());
if(args.isEmpty())
{
diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/DebugCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/DebugCmd.java
index 90495b3..9cc597c 100644
--- a/src/main/java/com/jagrosh/vortex/commands/owner/DebugCmd.java
+++ b/src/main/java/com/jagrosh/vortex/commands/owner/DebugCmd.java
@@ -36,7 +36,7 @@
{
this.vortex = vortex;
this.name = "debug";
- this.help = "shows some debug stats ";
+ this.help = "shows some debug stats";
this.ownerCommand = true;
this.guildOnly = false;
this.hidden = true;
diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/TransferCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/TransferCmd.java
new file mode 100644
index 0000000..e4466ee
--- /dev/null
+++ b/src/main/java/com/jagrosh/vortex/commands/owner/TransferCmd.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2018 John Grosh (jagrosh).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jagrosh.vortex.commands.owner;
+
+import com.jagrosh.jdautilities.command.Command;
+import com.jagrosh.jdautilities.command.CommandEvent;
+import com.jagrosh.vortex.Vortex;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import net.dv8tion.jda.core.entities.Guild;
+import net.dv8tion.jda.core.entities.TextChannel;
+
+/**
+ *
+ * @author John Grosh (jagrosh)
+ */
+public class TransferCmd extends Command
+{
+ private final Vortex vortex;
+
+ public TransferCmd(Vortex vortex)
+ {
+ this.vortex = vortex;
+ this.name = "transfer";
+ this.help = "transfers old settings";
+ this.ownerCommand = true;
+ this.guildOnly = false;
+ this.hidden = true;
+ }
+
+ @Override
+ protected void execute(CommandEvent event)
+ {
+ try
+ {
+ List list = Files.readAllLines(Paths.get("transfer.txt"));
+ HashMap oldSettings = new HashMap<>();
+ list.stream().map(str -> str.split(" ")).forEach(split -> oldSettings.put(Long.parseLong(split[0]), split));
+ int mcount = 0;
+ int count = 0;
+ for(Guild g: vortex.getShardManager().getGuilds())
+ {
+ if(!oldSettings.containsKey(g.getIdLong()))
+ continue;
+ if(vortex.getDatabase().settings.hasSettings(g))
+ continue;
+ if(vortex.getDatabase().automod.hasSettings(g))
+ continue;
+ String[] split = oldSettings.get(g.getIdLong());
+ int maxmentions = Integer.parseInt(split[4]);
+ TextChannel modlog = g.getTextChannelById(Long.parseLong(split[5]));
+ boolean autoraid = Boolean.parseBoolean(split[6]);
+ int spamLimit = Integer.parseInt(split[2]);
+ if("N".equalsIgnoreCase(split[3]))
+ spamLimit = 0;
+ int inviteStrikes = "N".equalsIgnoreCase(split[1]) ? 0 : 1;
+ if(modlog!=null)
+ {
+ vortex.getDatabase().settings.setModLogChannel(g, modlog);
+ mcount++;
+ }
+ if(maxmentions<7 && autoraid==false && spamLimit<=3 && inviteStrikes==0)
+ continue;
+ if(vortex.getDatabase().actions.useDefaultSettings(g))
+ {
+ count++;
+ if(autoraid)
+ vortex.getDatabase().automod.setAutoRaidMode(g, 10, 10);
+ if(maxmentions>=7)
+ vortex.getDatabase().automod.setMaxMentions(g, maxmentions);
+ if(inviteStrikes>0)
+ vortex.getDatabase().automod.setInviteStrikes(g, inviteStrikes);
+ if(spamLimit>3)
+ vortex.getDatabase().automod.setDupeSettings(g, 1, 3, spamLimit);
+ }
+ }
+ event.replySuccess("Complete!\nLoaded: "+oldSettings.size()+"\nModlogs: "+mcount+"\nAutomod: "+count);
+ }
+ catch(Exception ex)
+ {
+ event.replyError("Error: "+ex+"\nat "+ex.getStackTrace()[0]);
+
+ }
+ }
+}
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 ac5505e..1b06221 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java
@@ -109,6 +109,11 @@
/*+ "\u200B"*/, true);
}
+ public boolean hasSettings(Guild guild)
+ {
+ return read(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> {return rs.next();});
+ }
+
// Setters
public void disableMaxMentions(Guild guild)
{
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 21a8b75..b8a6868 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java
@@ -42,6 +42,7 @@
{
public final static int PREFIX_MAX_LENGTH = 40;
private static final String SETTINGS_TITLE = "\uD83D\uDCCA Server Settings";
+ private static final ZoneId DEFAULT_TIMEZONE = ZoneId.of("GMT+4");
public final static SQLColumn GUILD_ID = new LongColumn("GUILD_ID",false,0L,true);
public final static SQLColumn MOD_ROLE_ID = new LongColumn("MOD_ROLE_ID",false,0L);
@@ -98,6 +99,11 @@
+ "\nTimezone: **"+settings.timezone+"**\n\u200B", true);
}
+ public boolean hasSettings(Guild guild)
+ {
+ return read(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> {return rs.next();});
+ }
+
// Setters
public void setModLogChannel(Guild guild, TextChannel tc)
{
@@ -349,7 +355,7 @@
this.avatarlog = AVATARLOG_ID.getValue(rs);
this.prefix = PREFIX.getValue(rs);
String str = TIMEZONE.getValue(rs);
- this.timezone = str==null ? ZoneId.systemDefault() : ZoneId.of(str);
+ this.timezone = str==null ? DEFAULT_TIMEZONE : ZoneId.of(str);
this.raidMode = RAIDMODE.getValue(rs);
}
diff --git a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java
index 2b58608..f2c758e 100644
--- a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java
+++ b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java
@@ -44,9 +44,9 @@
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+"punishment` command!";
- private static final int[] DEFAULT_STRIKE_COUNTS = {2, 3, 4, 5, 6, 7, 8};
- private static final Action[] DEFAULT_ACTIONS = {Action.TEMPMUTE, Action.TEMPMUTE, Action.KICK, Action.SOFTBAN, Action.TEMPMUTE, Action.TEMPBAN, Action.BAN};
- private static final int[] DEFAULT_TIMES = {10, 120, 0, 0, 1440, 1440, 0};
+ private static final int[] DEFAULT_STRIKE_COUNTS = {2, 3, 4, 5, 6};
+ private static final Action[] DEFAULT_ACTIONS = {Action.TEMPMUTE, Action.TEMPMUTE, Action.KICK, Action.TEMPBAN, Action.BAN};
+ private static final int[] DEFAULT_TIMES = {10, 120, 0, 1440, 0};
public static final SQLColumn GUILD_ID = new LongColumn("GUILD_ID", false, 0L);
public static final SQLColumn NUM_STRIKES = new IntegerColumn("NUM_STRIKES", false, 0);
diff --git a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
index 31fa892..43dd1ec 100644
--- a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
+++ b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java
@@ -73,6 +73,16 @@
return Character.toUpperCase(input.charAt(0))+input.substring(1).toLowerCase();
}
+ public static String join(String delimiter, char... items)
+ {
+ if(items==null || items.length==0)
+ return "";
+ StringBuilder sb = new StringBuilder().append(items[0]);
+ for(int i=1; i String join(String delimiter, Function function, T... items)
{
if(items==null || items.length==0)