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 9901715..462b4f1 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AntiduplicateCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntiduplicateCmd.java @@ -17,7 +17,6 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.vortex.Constants; import net.dv8tion.jda.core.Permission; import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.database.managers.PunishmentManager; @@ -48,7 +47,7 @@ if(event.getArgs().isEmpty() || event.getArgs().equalsIgnoreCase("help")) { event.replySuccess("The Anti-Duplicate system prevents and punishes users for sending the same message repeatedly.\n" - + "Usage: `"+Constants.PREFIX+name+" "+arguments+"`\n" + + "Usage: `"+event.getClient().getPrefix()+name+" "+arguments+"`\n" + "`` - the number of duplicates at which strikes should start being assigned\n" + "`[delete threshold]` - the number of duplicates at which a user's messages should start being deleted\n" + "`[strikes]` - the number of strikes to assign on each duplicate after the strike threshold is met"); diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java index f51ccc3..8212b08 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/FilterCmd.java @@ -57,7 +57,7 @@ + "quote can be checked for by surrounding the word in double quotation marks (\"). \n"); for(Command cmd: children) { - sb.append("\n`").append(Constants.PREFIX).append(name).append(" ").append(cmd.getName()) + sb.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ").append(cmd.getName()) .append(cmd.getArguments() == null ? "" : " " + cmd.getArguments()).append("` - ").append(cmd.getHelp()); } event.reply(sb.toString()); diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java index 41787b1..a41d603 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/UnignoreCmd.java @@ -18,7 +18,6 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; -import com.jagrosh.vortex.Constants; import com.jagrosh.vortex.Vortex; import java.util.List; import net.dv8tion.jda.core.Permission; @@ -79,7 +78,7 @@ event.replySuccess("Automod is no longer ignoring role `"+roles.get(0).getName()+"`"); else event.replyError("Automod was not ignoring role `"+roles.get(0).getName()+"`" - + "\n"+Constants.WARNING+" If this role is still listed when using `"+Constants.PREFIX+"ignore`:" + + "\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"); } 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 ff46e75..135ac7b 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/RaidCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/RaidCmd.java @@ -16,7 +16,6 @@ package com.jagrosh.vortex.commands.moderation; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.vortex.Constants; import com.jagrosh.vortex.Vortex; import com.jagrosh.vortex.commands.ModCommand; import net.dv8tion.jda.core.Permission; @@ -65,8 +64,8 @@ else { event.replySuccess("Anti-Raid Mode is currently `"+(active ? "ACTIVE" : "NOT ACTIVE")+"`\n\n" - + "`"+Constants.PREFIX+name+" ON` to enable Anti-Raid Mode\n" - + "`"+Constants.PREFIX+name+" OFF` to disable Anti-Raid Mode"); + + "`"+event.getClient().getPrefix()+name+" ON` to enable Anti-Raid Mode\n" + + "`"+event.getClient().getPrefix()+name+" OFF` to disable Anti-Raid Mode"); } } } diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java index 4524f9c..6a946ca 100644 --- a/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/owner/PremiumCmd.java @@ -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 com.jagrosh.vortex.database.managers.PremiumManager.PremiumInfo; @@ -77,6 +76,6 @@ PremiumInfo before = vortex.getDatabase().premium.getPremiumInfo(guild); vortex.getDatabase().premium.addPremium(guild, PremiumManager.Level.PRO, seconds, ChronoUnit.SECONDS); PremiumInfo after = vortex.getDatabase().premium.getPremiumInfo(guild); - event.replySuccess("Before: " + before + "\n" + Constants.SUCCESS + " After: " + after); + event.replySuccess("Before: " + before + "\n" + event.getClient().getSuccess() + " After: " + after); } } diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/PrefixCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/PrefixCmd.java index 90d31bd..7537cc4 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/PrefixCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/PrefixCmd.java @@ -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.GuildSettingsDataManager; import net.dv8tion.jda.core.Permission; @@ -46,7 +45,7 @@ { if(event.getArgs().isEmpty()) { - event.replyError("Please include a prefix. The server's current prefix can be seen via the `"+Constants.PREFIX+"settings` command"); + event.replyError("Please include a prefix. The server's current prefix can be seen via the `"+event.getClient().getPrefix()+"settings` command"); return; } @@ -65,6 +64,6 @@ vortex.getDatabase().settings.setPrefix(event.getGuild(), event.getArgs()); event.replySuccess("The server prefix has been set to `"+event.getArgs()+"`\n" - + "Note that the default prefix (`"+Constants.PREFIX+"`) cannot be removed and will work in addition to the custom prefix."); + + "Note that the default prefix (`"+event.getClient().getPrefix()+"`) cannot be removed and will work in addition to the custom prefix."); } } 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 7ca5235..56a4b03 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java @@ -56,7 +56,7 @@ { StringBuilder sb = new StringBuilder("The following commands can be used to set up a **").append(event.getSelfUser().getName()).append("** feature:\n"); for(Command cmd: children) - sb.append("\n`").append(Constants.PREFIX).append(name).append(" ").append(cmd.getName()).append("` - ").append(cmd.getHelp()); + sb.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ").append(cmd.getName()).append("` - ").append(cmd.getHelp()); event.replySuccess(sb.toString()); } @@ -83,54 +83,54 @@ event.getChannel().sendTyping().queue(); StringBuilder sb = new StringBuilder("**Automod setup complete!**"); if(vortex.getDatabase().actions.useDefaultSettings(event.getGuild())) - sb.append("\n").append(Constants.SUCCESS).append(" Set up default punishments"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Set up default punishments"); AutomodSettings ams = vortex.getDatabase().automod.getSettings(event.getGuild()); if(ams.inviteStrikes==0) { vortex.getDatabase().automod.setInviteStrikes(event.getGuild(), 2); - sb.append("\n").append(Constants.SUCCESS).append(" Anti-invite set to `2` strikes"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Anti-invite set to `2` strikes"); } if(ams.refStrikes==0) { vortex.getDatabase().automod.setRefStrikes(event.getGuild(), 3); - sb.append("\n").append(Constants.SUCCESS).append(" Anti-referral set to `3` strikes"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Anti-referral set to `3` strikes"); } if(!ams.useAntiDuplicate()) { vortex.getDatabase().automod.setDupeSettings(event.getGuild(), 1, 2, 4); - sb.append("\n").append(Constants.SUCCESS).append(" Anti-duplicate will start deleting at duplicate `2`, and will assign `1` strike each duplicate starting at duplicate `4`"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Anti-duplicate will start deleting at duplicate `2`, and will assign `1` strike each duplicate starting at duplicate `4`"); } if(ams.copypastaStrikes==0) { vortex.getDatabase().automod.setCopypastaStrikes(event.getGuild(), 1); - sb.append("\n").append(Constants.SUCCESS).append(" Anti-copypasta set to `1` strikes"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Anti-copypasta set to `1` strikes"); } if(ams.maxMentions==0) { vortex.getDatabase().automod.setMaxMentions(event.getGuild(), 10); - sb.append("\n").append(Constants.SUCCESS).append(" Maximum mentions set to `10` mentions"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Maximum mentions set to `10` mentions"); } if(ams.maxRoleMentions==0) { vortex.getDatabase().automod.setMaxRoleMentions(event.getGuild(), 4); - sb.append("\n").append(Constants.SUCCESS).append(" Maximum role mentions set to `4` mentions"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Maximum role mentions set to `4` mentions"); } if(ams.maxLines==0) { vortex.getDatabase().automod.setMaxLines(event.getGuild(), 10); - sb.append("\n").append(Constants.SUCCESS).append(" Maximum lines set to `10` lines"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Maximum lines set to `10` lines"); } if(!ams.useAutoRaidMode()) { vortex.getDatabase().automod.setAutoRaidMode(event.getGuild(), 10, 10); - sb.append("\n").append(Constants.SUCCESS).append(" Anti-Raid Mode will activate upon `10` joins in `10` seconds"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Anti-Raid Mode will activate upon `10` joins in `10` seconds"); } if(ams.dehoistChar==(char)0) { vortex.getDatabase().automod.setDehoistChar(event.getGuild(), '!'); - sb.append("\n").append(Constants.SUCCESS).append(" Names starting with `!` will be dehoisted"); + sb.append("\n").append(event.getClient().getSuccess()).append(" Names starting with `!` will be dehoisted"); } - sb.append("\n").append(Constants.WARNING).append(" Any settings not shown here were not set due to being already set. Please check the automod section of the wiki (<") + sb.append("\n").append(event.getClient().getWarning()).append(" Any settings not shown here were not set due to being already set. Please check the automod section of the wiki (<") .append(Constants.Wiki.AUTOMOD).append(">) for more information about the automod."); event.replySuccess(sb.toString()); }); @@ -179,7 +179,7 @@ private void setUpMutedRole(CommandEvent event, Role role) { - StringBuilder sb = new StringBuilder(Constants.SUCCESS+" Muted role setup started!\n"); + StringBuilder sb = new StringBuilder(event.getClient().getSuccess()+" Muted role setup started!\n"); event.reply(sb + Constants.LOADING+" Initializing role...", m -> event.async(() -> { try @@ -194,7 +194,7 @@ role.getManager().setPermissions().complete(); mutedRole = role; } - sb.append(Constants.SUCCESS+" Role initialized!\n"); + sb.append(event.getClient().getSuccess()).append(" Role initialized!\n"); m.editMessage(sb + Constants.LOADING+" Making Category overrides...").complete(); PermissionOverride po; for(net.dv8tion.jda.core.entities.Category cat: event.getGuild().getCategories()) @@ -205,7 +205,7 @@ else po.getManager().deny(Permission.MESSAGE_WRITE, Permission.MESSAGE_ADD_REACTION, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK).complete(); } - sb.append(Constants.SUCCESS+" Category overrides complete!\n"); + sb.append(event.getClient().getSuccess()).append(" Category overrides complete!\n"); m.editMessage(sb + Constants.LOADING + " Making Text Channel overrides...").complete(); for(TextChannel tc: event.getGuild().getTextChannels()) { @@ -215,7 +215,7 @@ else po.getManager().deny(Permission.MESSAGE_WRITE, Permission.MESSAGE_ADD_REACTION).complete(); } - sb.append(Constants.SUCCESS+" Text Channel overrides complete!\n"); + sb.append(event.getClient().getSuccess()).append(" Text Channel overrides complete!\n"); m.editMessage(sb + Constants.LOADING + " Making Voice Channel overrides...").complete(); for(VoiceChannel vc: event.getGuild().getVoiceChannels()) { @@ -225,11 +225,11 @@ else po.getManager().deny(Permission.VOICE_CONNECT, Permission.VOICE_SPEAK).complete(); } - m.editMessage(sb + Constants.SUCCESS+" Voice Channel overrides complete!\n\n" + Constants.SUCCESS+" Muted role setup has completed!").queue(); + m.editMessage(sb + event.getClient().getSuccess()+" Voice Channel overrides complete!\n\n" + event.getClient().getSuccess()+" Muted role setup has completed!").queue(); } catch(Exception ex) { - m.editMessage(sb + Constants.ERROR+" An error occurred setting up the Muted role. Please check that I have the Administrator permission and that the Muted role is below my roles.").queue(); + m.editMessage(sb + event.getClient().getError()+" An error occurred setting up the Muted role. Please check that I have the Administrator permission and that the Muted role is below my roles.").queue(); } })); } @@ -240,7 +240,7 @@ .setChoices(CONFIRM, CANCEL) .setEventWaiter(vortex.getEventWaiter()) .setTimeout(1, TimeUnit.MINUTES) - .setText(Constants.WARNING+" "+message+"\n\n"+CONFIRM+" Continue\n"+CANCEL+" Cancel") + .setText(event.getClient().getWarning()+" "+message+"\n\n"+CONFIRM+" Continue\n"+CANCEL+" Cancel") .setFinalAction(m -> m.delete().queue(s->{}, f->{})) .setUsers(event.getAuthor()) .setAction(re -> diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/AuditCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/AuditCmd.java index 90b31a6..f023d8f 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/AuditCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/AuditCmd.java @@ -18,8 +18,6 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; -import com.jagrosh.vortex.Action; -import com.jagrosh.vortex.Constants; import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException; import com.jagrosh.vortex.commands.CommandExceptionListener.CommandWarningException; import com.jagrosh.vortex.utils.FormatUtil; @@ -29,6 +27,7 @@ import net.dv8tion.jda.core.MessageBuilder; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.audit.ActionType; +import net.dv8tion.jda.core.audit.AuditLogChange; import net.dv8tion.jda.core.entities.Emote; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.TextChannel; @@ -100,9 +99,9 @@ break; default: throw new CommandErrorException("Valid subcommands:\n\n" - + "`" + Constants.PREFIX + name + " all` - shows recent audit log entries\n" - + "`" + Constants.PREFIX + name + " from ` - shows recent entries by a user\n" - + "`" + Constants.PREFIX + name + " action ` shows recent entries of a certain action"); + + "`" + event.getClient().getPrefix() + name + " all` - shows recent audit log entries\n" + + "`" + event.getClient().getPrefix() + name + " from ` - shows recent entries by a user\n" + + "`" + event.getClient().getPrefix() + name + " action ` shows recent entries of a certain action"); } event.getChannel().sendTyping().queue(); action.queue(list -> @@ -156,10 +155,12 @@ } ale.getChanges().keySet().forEach(change -> { - sb.append("\n").append(LINESTART).append(fixCase(change)).append(": ") - .append(ale.getChangeByKey(change).getOldValue()==null ? "" : "**"+ale.getChangeByKey(change).getOldValue()+"**") - .append(ale.getChangeByKey(change).getOldValue()==null || ale.getChangeByKey(change).getNewValue()==null ? "" : " → ") - .append(ale.getChangeByKey(change).getNewValue()==null ? "" : "**"+ale.getChangeByKey(change).getNewValue()+"**"); + AuditLogChange alc = ale.getChangeByKey(change); + if(alc != null) + sb.append("\n").append(LINESTART).append(fixCase(change)).append(": ") + .append(alc.getOldValue()==null ? "" : "**"+alc.getOldValue()+"**") + .append(alc.getOldValue()==null || alc.getNewValue()==null ? "" : " → ") + .append(alc.getNewValue()==null ? "" : "**"+alc.getNewValue()+"**"); }); ale.getOptions().keySet().forEach(option -> { @@ -173,7 +174,7 @@ eb.addField(actionToEmote(ale.getType())+" "+fixCase(ale.getType().name()), str, true); }); event.reply(new MessageBuilder() - .setContent(Constants.SUCCESS+" Recent Audit Logs in **"+FormatUtil.filterEveryone(event.getGuild().getName())+"**:") + .setContent(event.getClient().getSuccess()+" Recent Audit Logs in **"+FormatUtil.filterEveryone(event.getGuild().getName())+"**:") .setEmbed(eb.build()).build()); }, f -> event.replyWarning("Failed to retrieve audit logs")); } diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java index 1bdce00..60a5705 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java @@ -91,7 +91,7 @@ .setChoices(CONFIRM, CANCEL) .setEventWaiter(vortex.getEventWaiter()) .setTimeout(1, TimeUnit.MINUTES) - .setText(Constants.WARNING+" "+message+"\n\n"+CONFIRM+" Continue\n"+CANCEL+" Cancel") + .setText(event.getClient().getWarning()+" "+message+"\n\n"+CONFIRM+" Continue\n"+CANCEL+" Cancel") .setFinalAction(m -> m.delete().queue(s->{}, f->{})) .setUsers(event.getAuthor()) .setAction(re -> diff --git a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java index e8344c0..07a71b8 100644 --- a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java @@ -259,7 +259,7 @@ if(event.getArgs().isEmpty()) { commandsInCategory = Collections.EMPTY_LIST; - content = Constants.SUCCESS+" **"+event.getSelfUser().getName()+"** Commands Categories:"; + content = event.getClient().getSuccess()+" **"+event.getSelfUser().getName()+"** Commands Categories:"; } else { @@ -272,23 +272,23 @@ return cmd.getCategory().getName().toLowerCase().startsWith(event.getArgs().toLowerCase()); }).collect(Collectors.toList()); if(commandsInCategory.isEmpty()) - content = Constants.WARNING+" No Category `"+event.getArgs()+"` found."; + content = event.getClient().getWarning()+" No Category `"+event.getArgs()+"` found."; else - content = Constants.SUCCESS+" **"+event.getSelfUser().getName()+"** " + content = event.getClient().getSuccess()+" **"+event.getSelfUser().getName()+"** " +(commandsInCategory.get(0).getCategory()==null ? "General" : commandsInCategory.get(0).getCategory().getName()) +" Commands:"; } if(commandsInCategory.isEmpty()) { - builder.addField(CMD_EMOJI+" General Commands", "[**"+Constants.PREFIX+"help general**]("+Constants.Wiki.COMMANDS+"#-general-commands)\n\u200B", false); + builder.addField(CMD_EMOJI+" General Commands", "[**"+event.getClient().getPrefix()+"help general**]("+Constants.Wiki.COMMANDS+"#-general-commands)\n\u200B", false); event.getClient().getCommands().stream().filter(cmd -> cmd.getCategory()!=null).map(cmd -> cmd.getCategory().getName()).distinct() - .forEach(cat -> builder.addField(CMD_EMOJI+" "+cat+" Commands", "[**"+Constants.PREFIX+"help "+cat.toLowerCase()+"**](" + .forEach(cat -> builder.addField(CMD_EMOJI+" "+cat+" Commands", "[**"+event.getClient().getPrefix()+"help "+cat.toLowerCase()+"**](" +Constants.Wiki.COMMANDS+"#-"+cat.toLowerCase()+"-commands)\n\u200B", false)); } else { - commandsInCategory.forEach(cmd -> builder.addField(Constants.PREFIX+cmd.getName()+(cmd.getArguments()==null ? "" : " "+cmd.getArguments()), + commandsInCategory.forEach(cmd -> builder.addField(event.getClient().getPrefix()+cmd.getName()+(cmd.getArguments()==null ? "" : " "+cmd.getArguments()), "[**"+cmd.getHelp()+"**]("+Constants.Wiki.COMMANDS+"#-"+(cmd.getCategory()==null?"general":cmd.getCategory().getName().toLowerCase())+"-commands)\n\u200B", false)); }