diff --git a/.classpath b/.classpath index e147ff5..fa5c291 100644 --- a/.classpath +++ b/.classpath @@ -10,5 +10,6 @@ + diff --git a/src/pkg/deepCurse/nopalmo/command/CommandInterface.java b/src/pkg/deepCurse/nopalmo/command/CommandInterface.java index ee63735..d300435 100644 --- a/src/pkg/deepCurse/nopalmo/command/CommandInterface.java +++ b/src/pkg/deepCurse/nopalmo/command/CommandInterface.java @@ -8,8 +8,6 @@ import net.dv8tion.jda.api.Permission; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global; import pkg.deepCurse.nopalmo.manager.Argument; import pkg.deepCurse.nopalmo.manager.CommandBlob; -import pkg.deepCurse.nopalmo.manager.DirectCommandBlob; -import pkg.deepCurse.nopalmo.manager.GuildCommandBlob; public interface CommandInterface { // TODO rewrite to implement type args? @@ -42,11 +40,11 @@ public interface CommandInterface { // TODO rewrite to implement type args? StringBuilder sB = new StringBuilder(); for (Argument i : getArguments().values()) { if (!i.isDeveloper() || (hasPermissionInfo && i.isDeveloper())) { - sB.append(i.isRequired() ? "<" : "["); - if (i.getPrefixRequirement()) { - sB.append(Argument.argumentPrefix); - } - sB.append(i.getArgName() + (i.isRequired() ? "> " : "] ")); + sB.append(i.isRequired() ? "<" : "["); + if (i.getPrefixRequirement()) { + sB.append(Argument.argumentPrefix); + } + sB.append(i.getArgName() + (i.isRequired() ? "> " : "] ")); } } @@ -60,29 +58,27 @@ public interface CommandInterface { // TODO rewrite to implement type args? @Nullable public HashMap getArguments(); - public interface DualCommandInterface extends DirectCommandInterface, GuildCommandInterface { + public interface DualCommandInterface extends PrivateCommandInterface, GuildCommandInterface { @Override - public default void runGuildCommand(GuildCommandBlob blob, HashMap argumentMap) - throws Exception { - runDualCommand(new CommandBlob(blob), argumentMap); + public default void runGuildCommand(CommandBlob blob, HashMap argumentMap) throws Exception { + runDualCommand(blob, argumentMap); } @Override - public default void runDirectCommand(DirectCommandBlob blob, HashMap argumentMap) - throws Exception { - runDualCommand(new CommandBlob(blob), argumentMap); + public default void runDirectCommand(CommandBlob blob, HashMap argumentMap) throws Exception { + runDualCommand(blob, argumentMap); } public void runDualCommand(CommandBlob blob, HashMap argumentMap) throws Exception; } - public interface DirectCommandInterface extends CommandInterface { - public void runDirectCommand(DirectCommandBlob blob, HashMap argumentList) throws Exception; + public interface PrivateCommandInterface extends CommandInterface { + public void runDirectCommand(CommandBlob blob, HashMap argumentList) throws Exception; } public interface GuildCommandInterface extends CommandInterface { - public void runGuildCommand(GuildCommandBlob blob, HashMap argumentList) throws Exception; + public void runGuildCommand(CommandBlob blob, HashMap argumentList) throws Exception; public default Permission[] getRequiredPermissions() { return null; diff --git a/src/pkg/deepCurse/nopalmo/command/commands/general/Example.java b/src/pkg/deepCurse/nopalmo/command/commands/general/Example.java index 6955719..39187b1 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/general/Example.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/general/Example.java @@ -6,11 +6,11 @@ import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface; import pkg.deepCurse.nopalmo.manager.Argument; import pkg.deepCurse.nopalmo.manager.CommandBlob; -public class Example implements DualCommandInterface{ +public class Example implements DualCommandInterface { @Override public String[] getCommandCalls() { - return new String[] {"owo"}; + return new String[] { "owo" }; } @Override @@ -25,21 +25,21 @@ public class Example implements DualCommandInterface{ @Override public void runDualCommand(CommandBlob blob, HashMap argumentMap) throws Exception { - + blob.getChannel().sendMessage("owo").queue(); - + } - + @Override public HashMap getArguments() { HashMap args = new HashMap(); - + args.put("k", new Argument("k", (CommandBlob blob) -> { blob.getChannel().sendMessage("Dr. K").queue(); }).setPrefixRequirement(true).setAutoStartRunnable(true)); - + return args; - + } } diff --git a/src/pkg/deepCurse/nopalmo/command/commands/general/Prefix.java b/src/pkg/deepCurse/nopalmo/command/commands/general/Prefix.java index b718728..400840e 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/general/Prefix.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/general/Prefix.java @@ -7,7 +7,7 @@ import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Guild; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Users; import pkg.deepCurse.nopalmo.manager.Argument; -import pkg.deepCurse.nopalmo.manager.GuildCommandBlob; +import pkg.deepCurse.nopalmo.manager.CommandBlob; public class Prefix implements GuildCommandInterface { @@ -22,17 +22,19 @@ public class Prefix implements GuildCommandInterface { } @Override - public void runGuildCommand(GuildCommandBlob blob, HashMap argumentList) throws Exception { - + public void runGuildCommand(CommandBlob blob, HashMap argumentList) throws Exception { + if (argumentList.get("prefix") != null) { - Guild.Prefix.setPrefix( - blob.getEvent().getGuild().getIdLong(), argumentList.get("prefix").getWildCardString()); - blob.getEvent().getChannel().sendMessage("Set prefix to " + argumentList.get("prefix").getWildCardString()).queue(); - if (!Users.isAdvancedUser(blob.getUserID())) blob.getChannel().sendMessage("Remember: you can always ping me to use any command in case you forget the prefix").queue(); + Guild.Prefix.setPrefix(blob.getGuildID(), argumentList.get("prefix").getWildCardString()); + blob.getChannel().sendMessage("Set prefix to " + argumentList.get("prefix").getWildCardString()).queue(); + if (!Users.isAdvancedUser(blob.getAuthorID())) + blob.getChannel() + .sendMessage( + "Remember: you can always ping me to use any command in case you forget the prefix") + .queue(); } else { - Guild.Prefix.setPrefix( - blob.getEvent().getGuild().getIdLong(), Global.prefix); - blob.getEvent().getChannel().sendMessage("Reset prefix to default").queue(); + Guild.Prefix.setPrefix(blob.getGuildID(), Global.prefix); + blob.getChannel().sendMessage("Reset prefix to default").queue(); } } diff --git a/src/pkg/deepCurse/nopalmo/command/commands/general/Test.java b/src/pkg/deepCurse/nopalmo/command/commands/general/Test.java index 6807c49..5a99516 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/general/Test.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/general/Test.java @@ -6,13 +6,13 @@ import org.jetbrains.annotations.Nullable; import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface; import pkg.deepCurse.nopalmo.manager.Argument; -import pkg.deepCurse.nopalmo.manager.GuildCommandBlob; +import pkg.deepCurse.nopalmo.manager.CommandBlob; public class Test implements GuildCommandInterface { @Override public String[] getCommandCalls() { - return new String[] {"test"}; + return new String[] { "test" }; } @Override @@ -24,20 +24,20 @@ public class Test implements GuildCommandInterface { public String getHelp() { return "A command used to test various things"; } - + @Override public boolean isNSFW() { return true; } - + @Override public int getPremiumLevel() { return 1; } - + @Override - public void runGuildCommand(GuildCommandBlob blob, HashMap argumentList) throws Exception { - blob.getEvent().getChannel().sendMessage("Tested").queue(); + public void runGuildCommand(CommandBlob blob, HashMap argumentList) throws Exception { + blob.getChannel().sendMessage("Tested").queue(); } @Override diff --git a/src/pkg/deepCurse/nopalmo/command/commands/info/Git.java b/src/pkg/deepCurse/nopalmo/command/commands/info/Git.java index ac9a64d..c29a2ad 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/info/Git.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/info/Git.java @@ -28,9 +28,11 @@ public class Git implements DualCommandInterface { HashMap args = new HashMap(); args.put("test", new Argument("test", (CommandBlob blob) -> { - - blob.getChannel().sendMessage("This is the automatically running argument inside of " + this.getCommandName()).queue(); - + + blob.getChannel() + .sendMessage("This is the automatically running argument inside of " + this.getCommandName()) + .queue(); + }).setPrefixRequirement(true).setAutoStartRunnable(true).setDeveloper(true)); return args; @@ -40,5 +42,5 @@ public class Git implements DualCommandInterface { public String getHelp() { return "Posts my github link"; } - + } diff --git a/src/pkg/deepCurse/nopalmo/command/commands/info/Help.java b/src/pkg/deepCurse/nopalmo/command/commands/info/Help.java index 077f643..8e120ff 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/info/Help.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/info/Help.java @@ -6,12 +6,13 @@ import java.util.HashMap; import java.util.List; import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.TextChannel; import pkg.deepCurse.nopalmo.command.CommandInterface; import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global; import pkg.deepCurse.nopalmo.manager.Argument; +import pkg.deepCurse.nopalmo.manager.CommandBlob; import pkg.deepCurse.nopalmo.manager.CommandManager; -import pkg.deepCurse.nopalmo.manager.GuildCommandBlob; public class Help implements GuildCommandInterface { @@ -22,7 +23,7 @@ public class Help implements GuildCommandInterface { } @Override - public void runGuildCommand(GuildCommandBlob blob, HashMap argumentMap) throws Exception { + public void runGuildCommand(CommandBlob blob, HashMap argumentMap) throws Exception { boolean isDevEnabled = argumentMap.get("dev") != null; @@ -36,7 +37,7 @@ public class Help implements GuildCommandInterface { HashMap> commandHash = new HashMap>(); - for (GuildCommandInterface command : manager.getGuildCommands()) { + for (CommandInterface command : manager.getCommands()) { List commandNameList = commandHash.get(command.getHelpPage()); if (commandNameList == null) { commandNameList = new ArrayList(); @@ -70,25 +71,24 @@ public class Help implements GuildCommandInterface { StringBuilder sB = new StringBuilder(); - CommandInterface ping = blob.getCommandManager().getDirectCommand("ping"); + CommandInterface ping = blob.getCommandManager().getCommand("ping"); if (ping != null) { sB.append("`" + ping.getUsage(isDevEnabled) + "`\n"); } - CommandInterface info = blob.getCommandManager().getDirectCommand("info"); + CommandInterface info = blob.getCommandManager().getCommand("info"); if (info != null) { sB.append("`" + info.getUsage(isDevEnabled) + "`\n"); } - CommandInterface prefix = blob.getCommandManager().getDirectCommand("prefix"); + CommandInterface prefix = blob.getCommandManager().getCommand("prefix"); if (prefix != null) { sB.append("`" + prefix.getUsage(isDevEnabled) + "`\n"); } embed.addField("Information:", "Commands to take note of:\n" + sB, false); - embed.setFooter(blob.getEvent().getMember().getEffectiveName(), - blob.getEvent().getMember().getUser().getEffectiveAvatarUrl()); + embed.setFooter(blob.getMember().getEffectiveName(), blob.getAuthor().getEffectiveAvatarUrl()); embed.setTimestamp(Instant.now()); embed.setColor(Global.getEmbedColor()); @@ -97,11 +97,11 @@ public class Help implements GuildCommandInterface { return; } else if (argumentMap.get("commandName") != null) { - GuildCommandInterface command = manager.getGuildCommand(argumentMap.get("commandName").getWildCardString()); + CommandInterface command = manager.getCommand(argumentMap.get("commandName").getWildCardString()); if (command != null && ((deniedPages.contains(command.getHelpPage()) && isDevEnabled) || !deniedPages.contains(command.getHelpPage()))) { - if (!(command.isNSFW() && !blob.getChannel().isNSFW())) { + if (!blob.isFromGuild() ? true : !(command.isNSFW() && !((TextChannel) blob.getChannel()).isNSFW())) { EmbedBuilder eB = new EmbedBuilder(); eB.setColor(Global.getEmbedColor()); @@ -118,10 +118,9 @@ public class Help implements GuildCommandInterface { eB.addField("Page:", command.getHelpPage().toString(), true); // ("Page: " + // command.getHelpPage().toString()); - eB.setFooter(blob.getEvent().getMember().getEffectiveName(), - blob.getEvent().getMember().getUser().getEffectiveAvatarUrl()); + eB.setFooter(blob.getMember().getEffectiveName(), blob.getAuthor().getEffectiveAvatarUrl()); eB.setTimestamp(Instant.now()); - + if (command.getCommandCalls().length > 1) { sB.append("Aliases: "); for (int i = 1; i < command.getCommandCalls().length; i++) { @@ -134,9 +133,9 @@ public class Help implements GuildCommandInterface { sB.append("Is nsfw: " + command.isNSFW() + "\n"); } - if (command.getRequiredPermission() != null) { - sB.append("Required Permission: " + command.getRequiredPermission().getName() + "\n"); - } +// if (command.getRequiredPermission() != null) { +// sB.append("Required Permission: " + command.getRequiredPermission().getName() + "\n"); +// } if (command.getTimeout() > 0) { sB.append("Usage Timeout: " + command.getTimeout() + "\n"); diff --git a/src/pkg/deepCurse/nopalmo/command/commands/info/Info.java b/src/pkg/deepCurse/nopalmo/command/commands/info/Info.java index 0dbc0bd..67b4642 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/info/Info.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/info/Info.java @@ -4,15 +4,13 @@ import java.util.HashMap; import org.jetbrains.annotations.Nullable; -import pkg.deepCurse.nopalmo.command.CommandInterface.DirectCommandInterface; import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface; +import pkg.deepCurse.nopalmo.command.CommandInterface.PrivateCommandInterface; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Users; import pkg.deepCurse.nopalmo.manager.Argument; import pkg.deepCurse.nopalmo.manager.CommandBlob; -import pkg.deepCurse.nopalmo.manager.DirectCommandBlob; -import pkg.deepCurse.nopalmo.manager.GuildCommandBlob; -public class Info implements GuildCommandInterface, DirectCommandInterface { +public class Info implements GuildCommandInterface, PrivateCommandInterface { @Override public String[] getCommandCalls() { @@ -34,19 +32,18 @@ public class Info implements GuildCommandInterface, DirectCommandInterface { HashMap args = new HashMap(); args.put("userdump", new Argument("userdump", (CommandBlob blob) -> { - blob.getChannel().sendMessage(Users.dump(blob.getUserID())).queue(); - }).setPrefixRequirement(true).setAutoStartRunnable(true) - .setSkipOriginalTaskOnRunnable(true)); + blob.getChannel().sendMessage(Users.dump(blob.getAuthorID())).queue(); + }).setPrefixRequirement(true).setAutoStartRunnable(true).setSkipOriginalTaskOnRunnable(true)); return args; } @Override - public void runDirectCommand(DirectCommandBlob blob, HashMap argumentList) throws Exception { + public void runDirectCommand(CommandBlob blob, HashMap argumentList) throws Exception { } @Override - public void runGuildCommand(GuildCommandBlob blob, HashMap argumentList) throws Exception { + public void runGuildCommand(CommandBlob blob, HashMap argumentList) throws Exception { blob.getChannel().sendMessage("EEE").queue(); } } diff --git a/src/pkg/deepCurse/nopalmo/command/commands/info/Ping.java b/src/pkg/deepCurse/nopalmo/command/commands/info/Ping.java index ae251a4..d9fe42e 100644 --- a/src/pkg/deepCurse/nopalmo/command/commands/info/Ping.java +++ b/src/pkg/deepCurse/nopalmo/command/commands/info/Ping.java @@ -14,7 +14,7 @@ public class Ping implements DualCommandInterface { public void runDualCommand(CommandBlob blob, HashMap argumentMap) throws Exception { MessageChannel channel = blob.getChannel(); - + if (argumentMap.isEmpty()) { channel.sendMessage("Pong!\n" + blob.getJDA().getGatewayPing() + "ms\n").queue(); return; @@ -43,7 +43,7 @@ public class Ping implements DualCommandInterface { + (googlePing > 0 ? "Google: " + googlePing + "ms\n" : "Could not connect to www.google.com\n") + (discordPing > 0 ? "Discord: " + discordPing + "ms\n" : "Could not connect to www.discord.com\n") - + "JDA-Discord heartbeat: "+jdaPing+"ms"; + + "JDA-Discord heartbeat: " + jdaPing + "ms"; msg.editMessage(out + "\nTime to process: " + (System.currentTimeMillis() - timeToProcess) + "ms") .queue(); diff --git a/src/pkg/deepCurse/nopalmo/core/Boot.java b/src/pkg/deepCurse/nopalmo/core/Boot.java index 5330c53..b8dfa1c 100644 --- a/src/pkg/deepCurse/nopalmo/core/Boot.java +++ b/src/pkg/deepCurse/nopalmo/core/Boot.java @@ -14,11 +14,8 @@ import net.dv8tion.jda.api.utils.cache.CacheFlag; import pkg.deepCurse.nopalmo.database.DatabaseTools; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global; import pkg.deepCurse.nopalmo.global.Reactions; -import pkg.deepCurse.nopalmo.listener.DirectMessageReceivedListener; -import pkg.deepCurse.nopalmo.listener.GuildMessageReceivedListener; +import pkg.deepCurse.nopalmo.listener.MessageReceivedListener; import pkg.deepCurse.nopalmo.manager.CommandManager; -import pkg.deepCurse.nopalmo.manager.DirectCommandManager; -import pkg.deepCurse.nopalmo.manager.GuildCommandManager; import pkg.deepCurse.nopalmo.manager.StatusManager; import pkg.deepCurse.nopalmo.utils.Locks; import pkg.deepCurse.nopalmo.utils.LogHelper; @@ -116,8 +113,9 @@ public class Boot { .setAutoReconnect(true) - .addEventListeners(new GuildMessageReceivedListener()) - .addEventListeners(new DirectMessageReceivedListener()) +// .addEventListeners(new GuildMessageReceivedListener()) +// .addEventListeners(new DirectMessageReceivedListener()) + .addEventListeners(new MessageReceivedListener()) .setEnableShutdownHook(true) diff --git a/src/pkg/deepCurse/nopalmo/global/Reactions.java b/src/pkg/deepCurse/nopalmo/global/Reactions.java index 5cada68..e137091 100644 --- a/src/pkg/deepCurse/nopalmo/global/Reactions.java +++ b/src/pkg/deepCurse/nopalmo/global/Reactions.java @@ -4,12 +4,19 @@ import java.util.HashMap; public class Reactions { - private static HashMap reactionMap = new HashMap(); + private static final HashMap reactionMap = new HashMap(); + private static final HashMap internalReactionMap = new HashMap(); public static void init() { insert("galaxyThumb", 801657838358495232L); insert("kirbo_wadafuq", 799633705068003338L); - + + insertInternal("flushed", "U+1F633"); + insertInternal("eggplant", "U+1F346"); + } + + private static void insertInternal(String name, String emote) { + internalReactionMap.put(name, emote); } public static void insert(String input, long id) { @@ -17,11 +24,11 @@ public class Reactions { } public static String getReaction(String id) { - return ":" + id + ":" + reactionMap.get(id); + return id.startsWith(":") ? internalReactionMap.get(id.substring(1)) : ":" + id + ":" + reactionMap.get(id); } public static String getEmote(String id) { - return "<:" + id + ":" + reactionMap.get(id) + ">"; + return id.startsWith(":") ? internalReactionMap.get(id.substring(1)) : "<:" + id + ":" + reactionMap.get(id) + ">"; } } diff --git a/src/pkg/deepCurse/nopalmo/global/Tools.java b/src/pkg/deepCurse/nopalmo/global/Tools.java index 0509de5..c9eb1f1 100644 --- a/src/pkg/deepCurse/nopalmo/global/Tools.java +++ b/src/pkg/deepCurse/nopalmo/global/Tools.java @@ -8,11 +8,12 @@ public class Tools { public static void wrongUsage(MessageChannel messageChannel, CommandInterface command) { messageChannel.sendMessage("Wrong Command Usage!\n" + command.getUsage(false)).queue(); } - + public static void invalidPermissions(MessageChannel messageChannel, CommandInterface command) { - messageChannel.sendMessage("Sorry, but you are not allowed to use that! Try this:\n" + command.getUsage(false)).queue(); + messageChannel.sendMessage("Sorry, but you are not allowed to use that! Try this:\n" + command.getUsage(false)) + .queue(); } - + // public static void wrongUsage(MessageChannel tc, DirectCommandInterface c) { // tc.sendMessage("Wrong Command Usage!\n" + c.getUsage()).queue(); // } diff --git a/src/pkg/deepCurse/nopalmo/listener/DirectMessageReceivedListener.java b/src/pkg/deepCurse/nopalmo/listener/DirectMessageReceivedListener.java deleted file mode 100644 index dd9a6e9..0000000 --- a/src/pkg/deepCurse/nopalmo/listener/DirectMessageReceivedListener.java +++ /dev/null @@ -1,57 +0,0 @@ -package pkg.deepCurse.nopalmo.listener; - -import javax.annotation.Nonnull; - -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.events.ReadyEvent; -import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; -import pkg.deepCurse.nopalmo.core.Boot; -import pkg.deepCurse.nopalmo.database.DatabaseTools; -import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global; - -public class DirectMessageReceivedListener extends ListenerAdapter { - - @Override - public void onReady(@Nonnull ReadyEvent event) { - System.out.println("DirectMessageReceivedListener is now ready. . ."); - } - - @Override - public void onPrivateMessageReceived(@Nonnull PrivateMessageReceivedEvent event) { - Message message = event.getMessage(); - String messageRaw = message.getContentRaw(); - - if (messageRaw.contentEquals(Global.prefix + Global.prefix) - && DatabaseTools.Tools.Developers.canPowerOffBot(event.getAuthor().getIdLong())) { - - // message.addReaction(Reactions.getReaction("galaxyThumb")).complete(); - // TODO re enable - - event.getJDA().shutdown(); - System.exit(7); - } - - String[] prefixArray = new String[] { Global.prefix, "<@! " + event.getJDA().getSelfUser().getIdLong() + ">" }; - - boolean shouldReturn = true; - for (String i : prefixArray) { // TODO switch to [] to skip for loop? - - if (messageRaw.startsWith(i)) { - shouldReturn = false; - } - } - - // TODO add pre manager commands - - if (shouldReturn) { - return; - } - - if (!event.getAuthor().isBot()) { - Boot.commandManager.startCommand(event); - } - - } - -} diff --git a/src/pkg/deepCurse/nopalmo/listener/GuildMessageReceivedListener.java b/src/pkg/deepCurse/nopalmo/listener/MessageReceivedListener.java similarity index 67% rename from src/pkg/deepCurse/nopalmo/listener/GuildMessageReceivedListener.java rename to src/pkg/deepCurse/nopalmo/listener/MessageReceivedListener.java index e17a5d5..3270ef1 100644 --- a/src/pkg/deepCurse/nopalmo/listener/GuildMessageReceivedListener.java +++ b/src/pkg/deepCurse/nopalmo/listener/MessageReceivedListener.java @@ -4,33 +4,31 @@ import javax.annotation.Nonnull; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.ReadyEvent; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import pkg.deepCurse.nopalmo.core.Boot; import pkg.deepCurse.nopalmo.database.DatabaseTools; import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global; +import pkg.deepCurse.nopalmo.global.Reactions; -public class GuildMessageReceivedListener extends ListenerAdapter { +public class MessageReceivedListener extends ListenerAdapter { @Override public void onReady(@Nonnull ReadyEvent event) { - System.out.println("GuildMessageReceivedListener is now ready\n" + event.getGuildAvailableCount() + "/" + System.out.println("MessageReceivedListener is now ready\n" + event.getGuildAvailableCount() + "/" + event.getGuildTotalCount() + " : " + event.getGuildUnavailableCount() + " <" + event.getResponseNumber() + ">"); } @Override - public void onGuildMessageReceived(@Nonnull GuildMessageReceivedEvent event) { + public void onMessageReceived(@Nonnull MessageReceivedEvent event) { Message message = event.getMessage(); String messageRaw = message.getContentRaw(); if (messageRaw.contentEquals(Global.prefix + Global.prefix) && DatabaseTools.Tools.Developers.canPowerOffBot(event.getAuthor().getIdLong())) { - // message.addReaction(Reactions.getReaction("galaxyThumb")).complete(); - // TODO re enable - - message.delete().complete(); + message.addReaction(Reactions.getReaction(":eggplant")).complete(); event.getJDA().shutdown(); System.exit(7); diff --git a/src/pkg/deepCurse/nopalmo/manager/Argument.java b/src/pkg/deepCurse/nopalmo/manager/Argument.java index b72a5ea..1485693 100644 --- a/src/pkg/deepCurse/nopalmo/manager/Argument.java +++ b/src/pkg/deepCurse/nopalmo/manager/Argument.java @@ -30,7 +30,7 @@ public class Argument { private String permissionLevel = null; private boolean isRequired = false; private boolean isDeveloper = false; - + public static final String argumentPrefix = "-"; // This exists for the sole reason of customization and will // generally not change, ever, its recommended you keep it to // something other than empty to help ensure that what the user @@ -121,17 +121,17 @@ public class Argument { this.requiresPrefix = bool; return this; } - + public Argument setIsWildcard(Boolean bool) { - - if (this.position<=-1) { + + if (this.position <= -1) { throw new IllegalArgumentException("Cannot create a wildcard without a position; set a position first"); } - + this.isWildcard = bool; return this; } - + public Boolean getIsWildcard() { return isWildcard; } @@ -150,7 +150,7 @@ public class Argument { } public interface RunnableArg { - + public void run(CommandBlob blob); } @@ -165,7 +165,7 @@ public class Argument { } public Argument setAutoStartRunnable(boolean bool) { - this.autoStartRunnable = bool; + this.autoStartRunnable = bool; return this; } @@ -191,7 +191,7 @@ public class Argument { this.isDeveloper = true; return this; } - + public String getPermission() { return this.permissionLevel; } @@ -199,7 +199,7 @@ public class Argument { public boolean isRequired() { return this.isRequired; } - + public Argument setIsRequired(boolean bool) { this.isRequired = bool; return this; diff --git a/src/pkg/deepCurse/nopalmo/manager/CommandBlob.java b/src/pkg/deepCurse/nopalmo/manager/CommandBlob.java index 8ab1bcf..02b6af1 100644 --- a/src/pkg/deepCurse/nopalmo/manager/CommandBlob.java +++ b/src/pkg/deepCurse/nopalmo/manager/CommandBlob.java @@ -3,117 +3,164 @@ package pkg.deepCurse.nopalmo.manager; import java.util.ArrayList; import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.MessageChannel; -import net.dv8tion.jda.api.entities.PrivateChannel; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.Event; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class CommandBlob { - // CONTAINER/TRANSLATOR CLASS FOR COMMAND BLOBS + private CommandManager commandManager = null; + private ArrayList args = null; + + private long authorID = 0; + private long channelID = 0; + private long guildID = 0; + private long messageID = 0; private Event event = null; - private CommandManager commandManager = null; - private ArrayList args = null; private JDA bot = null; + private MessageChannel channel = null; + private User author = null; + private Guild guild = null; + private Member member = null; + private Message message = null; - private long userID = 0; - private long channelID = 0; + private boolean isWebhookMessage = false; + private boolean isFromGuild = false; - public CommandBlob(GuildMessageReceivedEvent event) { + public CommandBlob(MessageReceivedEvent event, CommandManager commandManager) { this.event = event; this.bot = event.getJDA(); + this.commandManager = commandManager; + + this.author = event.getAuthor(); + this.authorID = this.author.getIdLong(); + this.channel = event.getChannel(); + this.channelID = this.channel.getIdLong(); + this.message = event.getMessage(); + this.messageID = event.getMessageIdLong(); + this.isFromGuild = event.isFromGuild(); + if (this.isFromGuild) { + this.guild = event.getGuild(); + this.guildID = this.guild.getIdLong(); + this.member = event.getMember(); + this.isWebhookMessage = event.isWebhookMessage(); + } } - public CommandBlob(MessageReceivedEvent event) { - this.event = event; - this.bot = event.getJDA(); + public CommandManager getCommandManager() { + return commandManager; } - public CommandBlob(GuildCommandBlob blob) { - this.args = blob.getArgs(); - this.channelID = blob.getChannelID(); - this.commandManager = blob.getCommandManager(); - this.event = blob.getEvent(); - this.userID = blob.getUserID(); - this.bot = blob.getEvent().getJDA(); + public void setCommandManager(CommandManager commandManager) { + this.commandManager = commandManager; } - public CommandBlob(DirectCommandBlob blob) { - this.args = blob.getArgs(); - this.channelID = blob.getChannelID(); - this.commandManager = blob.getCommandManager(); - this.event = blob.getEvent(); - this.userID = blob.getUserID(); - this.bot = blob.getEvent().getJDA(); + public ArrayList getArgs() { + return args; + } + + public void setArgs(ArrayList args) { + this.args = args; + } + + public long getAuthorID() { + return authorID; + } + + public void setAuthorID(long authorID) { + this.authorID = authorID; } public long getChannelID() { return channelID; } - public CommandBlob setChannelID(long channelID) { + public void setChannelID(long channelID) { this.channelID = channelID; - return this; } - public MessageChannel getChannel() { - TextChannel textChannel = bot.getTextChannelById(channelID); - if (textChannel != null){ - return textChannel; - } - PrivateChannel privateChannel = bot.getPrivateChannelById(channelID); - if (privateChannel != null){ - return privateChannel; - } - return null; + public long getGuildID() { + return guildID; } - public MessageChannel getMessageChannel(long channelID) { - return bot.getTextChannelById(channelID); + public void setGuildID(long guildID) { + this.guildID = guildID; } - public long getUserID() { - return userID; + public long getMessageID() { + return messageID; + } + + public void setMessageID(long messageID) { + this.messageID = messageID; + } + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; } public JDA getJDA() { return bot; } - public CommandBlob setUserID(long userID) { - this.userID = userID; - return this; + public void setBot(JDA bot) { + this.bot = bot; } - public ArrayList getArgs() { - return args; + public MessageChannel getChannel() { + return channel; } - public CommandBlob setArgs(ArrayList args) { - this.args = args; - return this; + public void setChannel(MessageChannel messageChannel) { + this.channel = messageChannel; } - public CommandManager getCommandManager() { - return commandManager; - + public User getAuthor() { + return author; } - public CommandBlob setCommandManager(CommandManager commandManager) { - this.commandManager = commandManager; - return this; + public void setAuthor(User author) { + this.author = author; } - public Event getEvent() { - if (event instanceof GuildMessageReceivedEvent) { - return (GuildMessageReceivedEvent) event; - } else if (event instanceof MessageReceivedEvent) { - return (MessageReceivedEvent) event; - } else - return null; + public Member getMember() { + return member; } + public void setMember(Member member) { + this.member = member; + } + + public Message getMessage() { + return message; + } + + public void setMessage(Message message) { + this.message = message; + } + + public boolean isWebhookMessage() { + return isWebhookMessage; + } + + public void setWebhookMessage(boolean isWebhookMessage) { + this.isWebhookMessage = isWebhookMessage; + } + + public boolean isFromGuild() { + return isFromGuild; + } + + public void setFromGuild(boolean isFromGuild) { + this.isFromGuild = isFromGuild; + } } diff --git a/src/pkg/deepCurse/nopalmo/manager/CommandManager.java b/src/pkg/deepCurse/nopalmo/manager/CommandManager.java index 619520b..fabfbb8 100644 --- a/src/pkg/deepCurse/nopalmo/manager/CommandManager.java +++ b/src/pkg/deepCurse/nopalmo/manager/CommandManager.java @@ -12,12 +12,13 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.regex.Pattern; -import net.dv8tion.jda.api.events.Event; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; -import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; +import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import pkg.deepCurse.nopalmo.command.CommandInterface; -import pkg.deepCurse.nopalmo.command.CommandInterface.DirectCommandInterface; +import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface; import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface; +import pkg.deepCurse.nopalmo.command.CommandInterface.PrivateCommandInterface; +import pkg.deepCurse.nopalmo.command.commands.general.Example; import pkg.deepCurse.nopalmo.command.commands.general.Prefix; import pkg.deepCurse.nopalmo.command.commands.general.Test; import pkg.deepCurse.nopalmo.command.commands.info.Git; @@ -32,8 +33,9 @@ import pkg.deepCurse.nopalmo.global.Tools; public class CommandManager { - private final Map guildCommandMap = new HashMap<>(); - private final Map directCommandMap = new HashMap<>(); + private final Map commandMap = new HashMap<>(); + // private final Map directCommandMap = new + // HashMap<>(); private static Executor executor = null; public CommandManager() { @@ -42,75 +44,41 @@ public class CommandManager { } public void init() { - addCommand(new Help(this)); - addCommand(new Ping()); - addCommand(new Git()); - addCommand(new Prefix()); - addCommand(new Test()); - addCommand(new Info()); + addCommand(new Help(this));// guild + addCommand(new Ping()); // dual + addCommand(new Git()); // dual + addCommand(new Prefix()); // guild + addCommand(new Test()); // guild + addCommand(new Info()); // guild direct + addCommand(new Example()); // dual } private void addCommand(CommandInterface c) { - if (c instanceof DirectCommandInterface) { - addDirectCommand((DirectCommandInterface) c); - } - if (c instanceof GuildCommandInterface) { - addGuildCommand((GuildCommandInterface) c); - } - } - - private void addDirectCommand(DirectCommandInterface c) { - if (!directCommandMap.containsKey(c.getCommandName())) { - directCommandMap.put(c.getCommandName(), c); + if (!commandMap.containsKey(c.getCommandName())) { + commandMap.put(c.getCommandName(), c); } else { - directCommandMap.remove(c.getCommandName()); - directCommandMap.put(c.getCommandName(), c); + commandMap.remove(c.getCommandName()); + commandMap.put(c.getCommandName(), c); } } - public Collection getDirectCommands() { - return directCommandMap.values(); + public CommandInterface getCommand(String commandName) { + return commandMap.get(commandName); } - public DirectCommandInterface getDirectCommand(String commandName) { - if (commandName != null) { - return directCommandMap.get(commandName); - } - return null; + public Collection getCommands() { + return commandMap.values(); } - private void addGuildCommand(GuildCommandInterface c) { - if (!guildCommandMap.containsKey(c.getCommandName())) { - guildCommandMap.put(c.getCommandName(), c); - } else { - guildCommandMap.remove(c.getCommandName()); - guildCommandMap.put(c.getCommandName(), c); - } - } + public void startCommand(MessageReceivedEvent event) { // TODO split up more - public Collection getGuildCommands() { - return guildCommandMap.values(); - } - - public GuildCommandInterface getGuildCommand(String commandName) { - if (commandName != null) { - return guildCommandMap.get(commandName); - } - return null; - } - - public void startCommand(Event event) { - if (event instanceof GuildMessageReceivedEvent) { - startGuildCommand((GuildMessageReceivedEvent) event); - } else if (event instanceof PrivateMessageReceivedEvent) { - startDirectCommand((PrivateMessageReceivedEvent)event); - } else throw new IllegalArgumentException("Invalid type"); - } - - public void startDirectCommand(PrivateMessageReceivedEvent event){ - final String message = event.getMessage().getContentRaw(); - String prefix = Global.prefix; + String prefix = null; + if (event.isFromGuild()) { + prefix = DatabaseTools.Tools.Guild.Prefix.getPrefix(event.getGuild().getIdLong()); + } else { + prefix = Global.prefix; + } String pingPrefix = "<@!" + event.getJDA().getSelfUser().getIdLong() + ">"; String splicer = null; @@ -127,18 +95,15 @@ public class CommandManager { final String[] split = message.replaceFirst("(?i)" + Pattern.quote(splicer), "").split("\\s+"); final String commandCall = split[0].toLowerCase(); - if (guildCommandMap.containsKey(commandCall)) { + if (commandMap.containsKey(commandCall)) { final List args = Arrays.asList(split).subList(1, split.length); executor.execute(() -> { long commandStartTime = System.currentTimeMillis(); try { - // ArrayList newArguments = new ArrayList(); - // ArrayList commandFlags = new ArrayList(); - - DirectCommandBlob commandBlob = new DirectCommandBlob(event); - DirectCommandInterface command = directCommandMap.get(commandCall); + CommandBlob commandBlob = new CommandBlob(event, this); + CommandInterface command = commandMap.get(commandCall); HashMap argumentList = new HashMap(); boolean printTime = false; @@ -166,7 +131,7 @@ public class CommandManager { printTime = true; break; case "\\perm": - commandBlob.setUserID(380045419381784576L); + commandBlob.setAuthorID(380045419381784576L); break; case "\\del": event.getMessage().delete().queue(); @@ -190,7 +155,8 @@ public class CommandManager { if (command.getArguments().keySet().contains(pre)) { offset++; if (command.getArguments().get(pre).getPermission() == null - || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), + || DatabaseTools.Tools.Developers.hasPermission( + commandBlob.getAuthorID(), command.getArguments().get(pre).getPermission())) { if (command.getArguments().get(pre).isSkipOriginalTaskOnRunnable()) { remainsValid = false; @@ -198,8 +164,7 @@ public class CommandManager { argumentList.put(pre, command.getArguments().get(pre)); if (command.getArguments().get(pre).isAutoStartRunnable() && command.getArguments().get(pre).getRunnableArg() != null) { - command.getArguments().get(pre).getRunnableArg() - .run(new CommandBlob(commandBlob)); + command.getArguments().get(pre).getRunnableArg().run(commandBlob); } } else { Tools.invalidPermissions(event.getChannel(), command); @@ -213,7 +178,8 @@ public class CommandManager { } else { if (command.getArguments().get(x) != null) { if (command.getArguments().get(x).getPermission() == null - || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), + || DatabaseTools.Tools.Developers.hasPermission( + commandBlob.getAuthorID(), command.getArguments().get(x).getPermission())) { if (command.getArguments().get(x).isSkipOriginalTaskOnRunnable()) { remainsValid = false; @@ -222,8 +188,7 @@ public class CommandManager { offset++; if (command.getArguments().get(x).isAutoStartRunnable() && command.getArguments().get(x).getRunnableArg() != null) { - command.getArguments().get(x).getRunnableArg() - .run(new CommandBlob(commandBlob)); + command.getArguments().get(x).getRunnableArg().run(commandBlob); } } else { Tools.invalidPermissions(event.getChannel(), command); @@ -233,7 +198,7 @@ public class CommandManager { if (positionalArgs.get(i - offset) != null) { if (positionalArgs.get(i - offset).getPermission() == null || DatabaseTools.Tools.Developers.hasPermission( - commandBlob.getUserID(), + commandBlob.getAuthorID(), positionalArgs.get(i - offset).getPermission())) { if (positionalArgs.get(i - offset).isSkipOriginalTaskOnRunnable()) { remainsValid = false; @@ -247,8 +212,7 @@ public class CommandManager { } if (positionalArgs.get(i - offset).isAutoStartRunnable() && positionalArgs.get(i - offset).getRunnableArg() != null) { - positionalArgs.get(i - offset).getRunnableArg() - .run(new CommandBlob(commandBlob)); + positionalArgs.get(i - offset).getRunnableArg().run(commandBlob); } } else { Tools.invalidPermissions(event.getChannel(), command); @@ -267,14 +231,7 @@ public class CommandManager { } - if (command.isNSFW() && !commandBlob.getChannel().isNSFW()) { - commandBlob.getChannel().sendMessage( - "Sorry, but you cannot run this command here, maybe try somewhere more private?") - .queue(); - remainsValid = false; - } - - if (command.getPremiumLevel() > Users.getPremiumLevel(commandBlob.getUserID())) { + if (command.getPremiumLevel() > Users.getPremiumLevel(commandBlob.getAuthorID())) { commandBlob.getChannel().sendMessage( "Sorry, but you cannot run this command, it is premium subs only, of at least tier " + command.getPremiumLevel()) @@ -284,8 +241,23 @@ public class CommandManager { commandBlob.setCommandManager(this); + if (event.isFromGuild()) { + if (command.isNSFW() && !((TextChannel) commandBlob.getChannel()).isNSFW()) { + commandBlob.getChannel().sendMessage( + "Sorry, but you cannot run this command here, maybe try somewhere more private?") + .queue(); + remainsValid = false; + } + } + if (remainsValid) { - command.runDirectCommand(commandBlob, argumentList); + if (command instanceof DualCommandInterface) { + ((DualCommandInterface) command).runDualCommand(commandBlob, argumentList); + } else if (command instanceof GuildCommandInterface && event.isFromGuild()) { + ((GuildCommandInterface) command).runGuildCommand(commandBlob, argumentList); + } else if (command instanceof PrivateCommandInterface && !event.isFromGuild()) { + ((PrivateCommandInterface) command).runDirectCommand(commandBlob, argumentList); + } } if (printTime) { @@ -321,220 +293,4 @@ public class CommandManager { }); } } - - public void startGuildCommand(GuildMessageReceivedEvent event) { - - final String message = event.getMessage().getContentRaw(); - String prefix = DatabaseTools.Tools.Guild.Prefix.getPrefix(event.getGuild().getIdLong()); - String pingPrefix = "<@!" + event.getJDA().getSelfUser().getIdLong() + ">"; - - String splicer = null; - if (message.startsWith(pingPrefix + " ")) { - splicer = pingPrefix + " "; - } else if (message.startsWith(prefix)) { - splicer = prefix; - } else if (message.startsWith(pingPrefix)) { - splicer = pingPrefix; - } else { - return; - } - - final String[] split = message.replaceFirst("(?i)" + Pattern.quote(splicer), "").split("\\s+"); - final String command = split[0].toLowerCase(); - - if (guildCommandMap.containsKey(command)) { - final List args = Arrays.asList(split).subList(1, split.length); - - executor.execute(() -> { - long commandStartTime = System.currentTimeMillis(); - - try { - // ArrayList newArguments = new ArrayList(); - // ArrayList commandFlags = new ArrayList(); - - GuildCommandBlob commandBlob = new GuildCommandBlob(event); - GuildCommandInterface guildCommand = guildCommandMap.get(command); - HashMap argumentList = new HashMap(); - - boolean printTime = false; - byte argSkipCount = 0; - boolean remainsValid = true; - - HashMap positionalArgs = new HashMap(); - - if (guildCommand.getArguments() != null) { - for (Argument i : guildCommand.getArguments().values()) { - if (i.getPosition() >= 0) { - positionalArgs.put(i.getPosition(), i); - } - } - } - - List newArgs = new ArrayList(); - - int offset = 0; - for (int i = 0; i < args.size(); i++) { - String x = args.get(i); - x = x.toLowerCase(); - switch (x) { - case "\\time": - printTime = true; - break; - case "\\perm": - commandBlob.setUserID(380045419381784576L); - break; - case "\\del": - event.getMessage().delete().queue(); - break; - default: - newArgs.add(x); - break; - } - } - // split up so global commands are actually global, and will not be affected by - // neighboring local args - for (int i = 0; i < newArgs.size(); i++) { - String x = newArgs.get(i); - x = x.toLowerCase(); - if (argSkipCount <= 0) { - if (guildCommand.getArguments() != null) { - - if (x.startsWith(Argument.argumentPrefix)) { - - String pre = x.substring(Argument.argumentPrefix.length()); - if (guildCommand.getArguments().keySet().contains(pre)) { - offset++; - if (guildCommand.getArguments().get(pre).getPermission() == null - || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), - guildCommand.getArguments().get(pre).getPermission())) { - if (guildCommand.getArguments().get(pre).isSkipOriginalTaskOnRunnable()) { - remainsValid = false; - } - argumentList.put(pre, guildCommand.getArguments().get(pre)); - if (guildCommand.getArguments().get(pre).isAutoStartRunnable() - && guildCommand.getArguments().get(pre).getRunnableArg() != null) { - guildCommand.getArguments().get(pre).getRunnableArg() - .run(new CommandBlob(commandBlob)); - } - } else { - Tools.invalidPermissions(event.getChannel(), guildCommand); - remainsValid = false; - } - - } else { - Tools.wrongUsage(event.getChannel(), guildCommand); - remainsValid = false; - } - } else { - if (guildCommand.getArguments().get(x) != null) { - if (guildCommand.getArguments().get(x).getPermission() == null - || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), - guildCommand.getArguments().get(x).getPermission())) { - if (guildCommand.getArguments().get(x).isSkipOriginalTaskOnRunnable()) { - remainsValid = false; - } - argumentList.put(x, guildCommand.getArguments().get(x)); - offset++; - if (guildCommand.getArguments().get(x).isAutoStartRunnable() - && guildCommand.getArguments().get(x).getRunnableArg() != null) { - guildCommand.getArguments().get(x).getRunnableArg() - .run(new CommandBlob(commandBlob)); - } - } else { - Tools.invalidPermissions(event.getChannel(), guildCommand); - remainsValid = false; - } - } else { - if (positionalArgs.get(i - offset) != null) { - if (positionalArgs.get(i - offset).getPermission() == null - || DatabaseTools.Tools.Developers.hasPermission( - commandBlob.getUserID(), - positionalArgs.get(i - offset).getPermission())) { - if (positionalArgs.get(i - offset).isSkipOriginalTaskOnRunnable()) { - remainsValid = false; - } - if (positionalArgs.get(i - offset).getIsWildcard()) { - argumentList.put(positionalArgs.get(i - offset).getArgName(), - positionalArgs.get(i - offset).setWildCardString(x)); - } else { - Tools.wrongUsage(event.getChannel(), guildCommand); - remainsValid = false; - } - if (positionalArgs.get(i - offset).isAutoStartRunnable() - && positionalArgs.get(i - offset).getRunnableArg() != null) { - positionalArgs.get(i - offset).getRunnableArg() - .run(new CommandBlob(commandBlob)); - } - } else { - Tools.invalidPermissions(event.getChannel(), guildCommand); - remainsValid = false; - } - } else - event.getChannel().sendMessage("pos is null").queue(); - } - } - - } else { - Tools.wrongUsage(event.getChannel(), guildCommand); - remainsValid = false; - } - } - - } - - if (guildCommand.isNSFW() && !commandBlob.getChannel().isNSFW()) { - commandBlob.getChannel().sendMessage( - "Sorry, but you cannot run this command here, maybe try somewhere more private?") - .queue(); - remainsValid = false; - } - - if (guildCommand.getPremiumLevel() > Users.getPremiumLevel(commandBlob.getUserID())) { - commandBlob.getChannel().sendMessage( - "Sorry, but you cannot run this command, it is premium subs only, of at least tier " - + guildCommand.getPremiumLevel()) - .queue(); - remainsValid = false; - } - - commandBlob.setCommandManager(this); - - if (remainsValid) { - guildCommand.runGuildCommand(commandBlob, argumentList); - } - - if (printTime) { - event.getChannel() - .sendMessage("Time to run: " + (System.currentTimeMillis() - commandStartTime) + "ms") - .queue(); - } - - } catch (Exception e) { - if (Boot.isProd) { - event.getChannel().sendMessage("```properties\n" + e + "```").queue(); - } else { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - event.getChannel().sendMessage("```properties\n" + sw.toString() + "```").queue(); - System.err.println("Exception caught in: " + e.toString()); - e.printStackTrace(); - } - } catch (Throwable t) { - - if (Boot.isProd) { - event.getChannel().sendMessage("```mathematica\n" + t + "```").queue(); - } else { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - t.printStackTrace(pw); - event.getChannel().sendMessage("```mathematica\n" + sw.toString() + "```").queue(); - System.err.println("Error caught in: " + t.toString()); - t.printStackTrace(); - } - } - }); - } - } - } diff --git a/src/pkg/deepCurse/nopalmo/manager/DirectCommandBlob.java b/src/pkg/deepCurse/nopalmo/manager/DirectCommandBlob.java deleted file mode 100644 index 968ee01..0000000 --- a/src/pkg/deepCurse/nopalmo/manager/DirectCommandBlob.java +++ /dev/null @@ -1,75 +0,0 @@ -package pkg.deepCurse.nopalmo.manager; - -import java.util.ArrayList; - -import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; - -public class DirectCommandBlob { - - private CommandManager commandManager = null; - private ArrayList args = null; - private PrivateMessageReceivedEvent event = null; - private JDA bot = null; - - private long userID = 0; - private long channelID = 0; - - public DirectCommandBlob(PrivateMessageReceivedEvent event) { - setUserID(event.getAuthor().getIdLong()); - setChannelID(event.getChannel().getIdLong()); - this.event = event; - this.bot = event.getJDA(); - } - - public ArrayList getArgs() { - return args; - } - - public TextChannel getChannel() { - TextChannel textChannel = bot.getTextChannelById(channelID); - if (textChannel != null) { - return textChannel; - } - return null; - } - - public DirectCommandBlob setArgs(ArrayList newArguments) { - this.args = newArguments; - return this; - } - - public DirectCommandBlob setUserID(long userID) { - this.userID = userID; - return this; - } - - public long getUserID() { - return this.userID; - } - - public CommandManager getCommandManager() { - return commandManager; - } - - public void setCommandManager(CommandManager commandManager) { - this.commandManager = commandManager; - } - - public long getChannelID() { - return channelID; - } - - public void setChannelID(long channelID) { - this.channelID = channelID; - } - - public PrivateMessageReceivedEvent getEvent() { - return event; - } - - public void setEvent(PrivateMessageReceivedEvent event) { - this.event = event; - } -} diff --git a/src/pkg/deepCurse/nopalmo/manager/DirectCommandManager.java b/src/pkg/deepCurse/nopalmo/manager/DirectCommandManager.java deleted file mode 100644 index 15a3e39..0000000 --- a/src/pkg/deepCurse/nopalmo/manager/DirectCommandManager.java +++ /dev/null @@ -1,261 +0,0 @@ -package pkg.deepCurse.nopalmo.manager; - -public class DirectCommandManager { -// -// private final Map directCommandMap = new HashMap<>(); -// private static Executor executor = null; -// -// public DirectCommandManager() { -// init(); -// executor = Executors.newCachedThreadPool(); -// } -// -// public void init() { -// -// for (CommandInterface i : Boot.guildCommandManager.getGuildCommands()) { -// -// if (i instanceof DualCommandInterface) { -// addDirectCommand((DualCommandInterface) i); -// } else if (i instanceof DirectCommandInterface) { -// addDirectCommand((DirectCommandInterface) i); -// } -// -// } -// -// } -// -// private void addDirectCommand(DirectCommandInterface c) { -// if (!directCommandMap.containsKey(c.getCommandName())) { -// directCommandMap.put(c.getCommandName(), c); -// } else { -// directCommandMap.remove(c.getCommandName()); -// directCommandMap.put(c.getCommandName(), c); -// } -// } -// -// public Collection getDirectCommands() { -// return directCommandMap.values(); -// } -// -// public DirectCommandInterface getDirectCommand(String commandName) { -// if (commandName != null) { -// return directCommandMap.get(commandName); -// } -// return null; -// } -// -// public void startCommand(MessageReceivedEvent directMessageEvent) { -// -// final String message = directMessageEvent.getMessage().getContentRaw(); -// String prefix = Global.prefix; -// String pingPrefix = "<@!" + directMessageEvent.getJDA().getSelfUser().getIdLong() + ">"; -// -// String splicer = null; -// if (message.startsWith(pingPrefix + " ")) { -// splicer = pingPrefix + " "; -// } else if (message.startsWith(prefix)) { -// splicer = prefix; -// } else if (message.startsWith(pingPrefix)) { -// splicer = pingPrefix; -// } else { -// return; -// } -// -// final String[] split = message.replaceFirst("(?i)" + Pattern.quote(splicer), "").split("\\s+"); -// final String command = split[0].toLowerCase(); -// -// if (directCommandMap.containsKey(command)) { -// final List args = Arrays.asList(split).subList(1, split.length); -// -// executor.execute(() -> { -// long commandStartTime = System.currentTimeMillis(); -// -// try { -// // ArrayList newArguments = new ArrayList(); -// // ArrayList commandFlags = new ArrayList(); -// -// DirectCommandBlob commandBlob = new DirectCommandBlob(directMessageEvent); -// DirectCommandInterface guildCommand = directCommandMap.get(command); -// HashMap argumentList = new HashMap(); -// -// boolean printTime = false; -// byte argSkipCount = 0; -// boolean remainsValid = true; -// -// HashMap positionalArgs = new HashMap(); -// -// if (guildCommand.getArguments() != null) { -// for (Argument i : guildCommand.getArguments().values()) { -// if (i.getPosition() >= 0) { -// positionalArgs.put(i.getPosition(), i); -// } -// } -// } -// -// List newArgs = new ArrayList(); -// -// int offset = 0; -// for (int i = 0; i < args.size(); i++) { -// String x = args.get(i); -// x = x.toLowerCase(); -// switch (x) { -// case "\\time": -// printTime = true; -// break; -// case "\\perm": -// commandBlob.setUserID(380045419381784576L); -// break; -// case "\\del": -// directMessageEvent.getMessage().delete().queue(); -// break; -// default: -// newArgs.add(x); -// break; -// } -// } -// // split up so global commands are actually global, and will not be affected by -// // neighboring local args -// for (int i = 0; i < newArgs.size(); i++) { -// String x = newArgs.get(i); -// x = x.toLowerCase(); -// if (argSkipCount <= 0) { -// if (guildCommand.getArguments() != null) { -// -// if (x.startsWith(Argument.argumentPrefix)) { -// -// String pre = x.substring(Argument.argumentPrefix.length()); -// if (guildCommand.getArguments().keySet().contains(pre)) { -// offset++; -// if (guildCommand.getArguments().get(pre).getPermission() == null -// || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), -// guildCommand.getArguments().get(pre).getPermission())) { -// if (guildCommand.getArguments().get(pre).isSkipOriginalTaskOnRunnable()) { -// remainsValid = false; -// } -// argumentList.put(pre, guildCommand.getArguments().get(pre)); -// if (guildCommand.getArguments().get(pre).isAutoStartRunnable() -// && guildCommand.getArguments().get(pre).getRunnableArg() != null) { -// guildCommand.getArguments().get(pre).getRunnableArg() -// .run(new CommandBlob(commandBlob)); -// } -// } else { -// Tools.invalidPermissions(directMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// -// } else { -// Tools.wrongUsage(directMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } else { -// if (guildCommand.getArguments().get(x) != null) { -// if (guildCommand.getArguments().get(x).getPermission() == null -// || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), -// guildCommand.getArguments().get(x).getPermission())) { -// if (guildCommand.getArguments().get(x).isSkipOriginalTaskOnRunnable()) { -// remainsValid = false; -// } -// argumentList.put(x, guildCommand.getArguments().get(x)); -// offset++; -// if (guildCommand.getArguments().get(x).isAutoStartRunnable() -// && guildCommand.getArguments().get(x).getRunnableArg() != null) { -// guildCommand.getArguments().get(x).getRunnableArg() -// .run(new CommandBlob(commandBlob)); -// } -// } else { -// Tools.invalidPermissions(directMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } else { -// if (positionalArgs.get(i - offset) != null) { -// if (positionalArgs.get(i - offset).getPermission() == null -// || DatabaseTools.Tools.Developers.hasPermission( -// commandBlob.getUserID(), -// positionalArgs.get(i - offset).getPermission())) { -// if (positionalArgs.get(i - offset).isSkipOriginalTaskOnRunnable()) { -// remainsValid = false; -// } -// if (positionalArgs.get(i - offset).getIsWildcard()) { -// argumentList.put(positionalArgs.get(i - offset).getArgName(), -// positionalArgs.get(i - offset).setWildCardString(x)); -// } else { -// Tools.wrongUsage(directMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// if (positionalArgs.get(i - offset).isAutoStartRunnable() -// && positionalArgs.get(i - offset).getRunnableArg() != null) { -// positionalArgs.get(i - offset).getRunnableArg() -// .run(new CommandBlob(commandBlob)); -// } -// } else { -// Tools.invalidPermissions(directMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } else -// directMessageEvent.getChannel().sendMessage("pos is null").queue(); -// } -// } -// -// } else { -// Tools.wrongUsage(directMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } -// -// } -// -// if (guildCommand.isNSFW() && !commandBlob.getChannel().isNSFW()) { -// commandBlob.getChannel().sendMessage( -// "Sorry, but you cannot run this command here, maybe try somewhere more private?") -// .queue(); -// remainsValid = false; -// } -// -// if (guildCommand.getPremiumLevel() > Users.getPremiumLevel(commandBlob.getUserID())) { -// commandBlob.getChannel().sendMessage( -// "Sorry, but you cannot run this command, it is premium subs only, of at least tier " -// + guildCommand.getPremiumLevel()) -// .queue(); -// remainsValid = false; -// } -// -// commandBlob.setCommandManager(this); -// -// if (remainsValid) { -// guildCommand.runDirectCommand(commandBlob, argumentList); -// } -// -// if (printTime) { -// directMessageEvent.getChannel() -// .sendMessage("Time to run: " + (System.currentTimeMillis() - commandStartTime) + "ms") -// .queue(); -// } -// -// } catch (Exception e) { -// if (Boot.isProd) { -// directMessageEvent.getChannel().sendMessage("```properties\n" + e + "```").queue(); -// } else { -// StringWriter sw = new StringWriter(); -// PrintWriter pw = new PrintWriter(sw); -// e.printStackTrace(pw); -// directMessageEvent.getChannel().sendMessage("```properties\n" + sw.toString() + "```").queue(); -// System.err.println("Exception caught in: " + e.toString()); -// e.printStackTrace(); -// } -// } catch (Throwable t) { -// -// if (Boot.isProd) { -// directMessageEvent.getChannel().sendMessage("```mathematica\n" + t + "```").queue(); -// } else { -// StringWriter sw = new StringWriter(); -// PrintWriter pw = new PrintWriter(sw); -// t.printStackTrace(pw); -// directMessageEvent.getChannel().sendMessage("```mathematica\n" + sw.toString() + "```").queue(); -// System.err.println("Error caught in: " + t.toString()); -// t.printStackTrace(); -// } -// } -// }); -// } -// } -} diff --git a/src/pkg/deepCurse/nopalmo/manager/GuildCommandBlob.java b/src/pkg/deepCurse/nopalmo/manager/GuildCommandBlob.java deleted file mode 100644 index 765d765..0000000 --- a/src/pkg/deepCurse/nopalmo/manager/GuildCommandBlob.java +++ /dev/null @@ -1,73 +0,0 @@ -package pkg.deepCurse.nopalmo.manager; - -import java.util.ArrayList; - -import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; - -public class GuildCommandBlob { - - private CommandManager commandManager = null; - private ArrayList args = null; - private JDA bot = null; - - private long userID = 0; - private long channelID = 0; - - private GuildMessageReceivedEvent event = null; - - public GuildCommandBlob(GuildMessageReceivedEvent event) { - this.event = event; - setUserID(event.getAuthor().getIdLong()); - setChannelID(event.getChannel().getIdLong()); - this.bot = event.getJDA(); - } - - public ArrayList getArgs() { - return args; - } - - public GuildCommandBlob setArgs(ArrayList newArguments) { - this.args = newArguments; - return this; - } - - public TextChannel getChannel() { - TextChannel textChannel = bot.getTextChannelById(channelID); - if (textChannel != null){ - return textChannel; - } - return null; - } - - public GuildCommandBlob setUserID(long userID) { - this.userID = userID; - return this; - } - - public long getUserID() { - return this.userID; - } - - public CommandManager getCommandManager() { - return commandManager; - } - - public void setCommandManager(CommandManager commandManager) { - this.commandManager = commandManager; - } - - public long getChannelID() { - return channelID; - } - - public void setChannelID(long channelID) { - this.channelID = channelID; - } - - public GuildMessageReceivedEvent getEvent() { - return event; - } - -} diff --git a/src/pkg/deepCurse/nopalmo/manager/GuildCommandManager.java b/src/pkg/deepCurse/nopalmo/manager/GuildCommandManager.java deleted file mode 100644 index 5f1b419..0000000 --- a/src/pkg/deepCurse/nopalmo/manager/GuildCommandManager.java +++ /dev/null @@ -1,256 +0,0 @@ -package pkg.deepCurse.nopalmo.manager; - -public class GuildCommandManager extends CommandManager { -// -// private final Map guildCommandMap = new HashMap<>(); -// private static Executor executor = null; -// -// public GuildCommandManager() { -// init(); -// executor = Executors.newWorkStealingPool();// newCachedThreadPool(); -// } -// -// public void init() { -// addCommand(new Help(this)); -// addCommand(new Ping()); -// addCommand(new Git()); -// addCommand(new Prefix()); -// addCommand(new Test()); -// addCommand(new Info()); -// } -// -// private void addCommand(GuildCommandInterface c) { -// if (!guildCommandMap.containsKey(c.getCommandName())) { -// guildCommandMap.put(c.getCommandName(), c); -// } else { -// guildCommandMap.remove(c.getCommandName()); -// guildCommandMap.put(c.getCommandName(), c); -// } -// } -// -// public Collection getGuildCommands() { -// return guildCommandMap.values(); -// } -// -// public GuildCommandInterface getDirectCommand(String commandName) { -// if (commandName != null) { -// return guildCommandMap.get(commandName); -// } -// return null; -// } -// -// public void startCommand(GuildMessageReceivedEvent guildMessageEvent) { -// -// final String message = guildMessageEvent.getMessage().getContentRaw(); -// String prefix = DatabaseTools.Tools.Guild.Prefix.getPrefix(guildMessageEvent.getGuild().getIdLong()); -// String pingPrefix = "<@!" + guildMessageEvent.getJDA().getSelfUser().getIdLong() + ">"; -// -// String splicer = null; -// if (message.startsWith(pingPrefix + " ")) { -// splicer = pingPrefix + " "; -// } else if (message.startsWith(prefix)) { -// splicer = prefix; -// } else if (message.startsWith(pingPrefix)) { -// splicer = pingPrefix; -// } else { -// return; -// } -// -// final String[] split = message.replaceFirst("(?i)" + Pattern.quote(splicer), "").split("\\s+"); -// final String command = split[0].toLowerCase(); -// -// if (guildCommandMap.containsKey(command)) { -// final List args = Arrays.asList(split).subList(1, split.length); -// -// executor.execute(() -> { -// long commandStartTime = System.currentTimeMillis(); -// -// try { -// // ArrayList newArguments = new ArrayList(); -// // ArrayList commandFlags = new ArrayList(); -// -// GuildCommandBlob commandBlob = new GuildCommandBlob(guildMessageEvent); -// GuildCommandInterface guildCommand = guildCommandMap.get(command); -// HashMap argumentList = new HashMap(); -// -// boolean printTime = false; -// byte argSkipCount = 0; -// boolean remainsValid = true; -// -// HashMap positionalArgs = new HashMap(); -// -// if (guildCommand.getArguments() != null) { -// for (Argument i : guildCommand.getArguments().values()) { -// if (i.getPosition() >= 0) { -// positionalArgs.put(i.getPosition(), i); -// } -// } -// } -// -// List newArgs = new ArrayList(); -// -// int offset = 0; -// for (int i = 0; i < args.size(); i++) { -// String x = args.get(i); -// x = x.toLowerCase(); -// switch (x) { -// case "\\time": -// printTime = true; -// break; -// case "\\perm": -// commandBlob.setUserID(380045419381784576L); -// break; -// case "\\del": -// guildMessageEvent.getMessage().delete().queue(); -// break; -// default: -// newArgs.add(x); -// break; -// } -// } -// // split up so global commands are actually global, and will not be affected by -// // neighboring local args -// for (int i = 0; i < newArgs.size(); i++) { -// String x = newArgs.get(i); -// x = x.toLowerCase(); -// if (argSkipCount <= 0) { -// if (guildCommand.getArguments() != null) { -// -// if (x.startsWith(Argument.argumentPrefix)) { -// -// String pre = x.substring(Argument.argumentPrefix.length()); -// if (guildCommand.getArguments().keySet().contains(pre)) { -// offset++; -// if (guildCommand.getArguments().get(pre).getPermission() == null -// || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), -// guildCommand.getArguments().get(pre).getPermission())) { -// if (guildCommand.getArguments().get(pre).isSkipOriginalTaskOnRunnable()) { -// remainsValid = false; -// } -// argumentList.put(pre, guildCommand.getArguments().get(pre)); -// if (guildCommand.getArguments().get(pre).isAutoStartRunnable() -// && guildCommand.getArguments().get(pre).getRunnableArg() != null) { -// guildCommand.getArguments().get(pre).getRunnableArg() -// .run(new CommandBlob(commandBlob)); -// } -// } else { -// Tools.invalidPermissions(guildMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// -// } else { -// Tools.wrongUsage(guildMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } else { -// if (guildCommand.getArguments().get(x) != null) { -// if (guildCommand.getArguments().get(x).getPermission() == null -// || DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(), -// guildCommand.getArguments().get(x).getPermission())) { -// if (guildCommand.getArguments().get(x).isSkipOriginalTaskOnRunnable()) { -// remainsValid = false; -// } -// argumentList.put(x, guildCommand.getArguments().get(x)); -// offset++; -// if (guildCommand.getArguments().get(x).isAutoStartRunnable() -// && guildCommand.getArguments().get(x).getRunnableArg() != null) { -// guildCommand.getArguments().get(x).getRunnableArg() -// .run(new CommandBlob(commandBlob)); -// } -// } else { -// Tools.invalidPermissions(guildMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } else { -// if (positionalArgs.get(i - offset) != null) { -// if (positionalArgs.get(i - offset).getPermission() == null -// || DatabaseTools.Tools.Developers.hasPermission( -// commandBlob.getUserID(), -// positionalArgs.get(i - offset).getPermission())) { -// if (positionalArgs.get(i - offset).isSkipOriginalTaskOnRunnable()) { -// remainsValid = false; -// } -// if (positionalArgs.get(i - offset).getIsWildcard()) { -// argumentList.put(positionalArgs.get(i - offset).getArgName(), -// positionalArgs.get(i - offset).setWildCardString(x)); -// } else { -// Tools.wrongUsage(guildMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// if (positionalArgs.get(i - offset).isAutoStartRunnable() -// && positionalArgs.get(i - offset).getRunnableArg() != null) { -// positionalArgs.get(i - offset).getRunnableArg() -// .run(new CommandBlob(commandBlob)); -// } -// } else { -// Tools.invalidPermissions(guildMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } else -// guildMessageEvent.getChannel().sendMessage("pos is null").queue(); -// } -// } -// -// } else { -// Tools.wrongUsage(guildMessageEvent.getChannel(), guildCommand); -// remainsValid = false; -// } -// } -// -// } -// -// if (guildCommand.isNSFW() && !commandBlob.getChannel().isNSFW()) { -// commandBlob.getChannel().sendMessage( -// "Sorry, but you cannot run this command here, maybe try somewhere more private?") -// .queue(); -// remainsValid = false; -// } -// -// if (guildCommand.getPremiumLevel() > Users.getPremiumLevel(commandBlob.getUserID())) { -// commandBlob.getChannel().sendMessage( -// "Sorry, but you cannot run this command, it is premium subs only, of at least tier " -// + guildCommand.getPremiumLevel()) -// .queue(); -// remainsValid = false; -// } -// -// commandBlob.setCommandManager(this); -// -// if (remainsValid) { -// guildCommand.runGuildCommand(commandBlob, argumentList); -// } -// -// if (printTime) { -// guildMessageEvent.getChannel() -// .sendMessage("Time to run: " + (System.currentTimeMillis() - commandStartTime) + "ms") -// .queue(); -// } -// -// } catch (Exception e) { -// if (Boot.isProd) { -// guildMessageEvent.getChannel().sendMessage("```properties\n" + e + "```").queue(); -// } else { -// StringWriter sw = new StringWriter(); -// PrintWriter pw = new PrintWriter(sw); -// e.printStackTrace(pw); -// guildMessageEvent.getChannel().sendMessage("```properties\n" + sw.toString() + "```").queue(); -// System.err.println("Exception caught in: " + e.toString()); -// e.printStackTrace(); -// } -// } catch (Throwable t) { -// -// if (Boot.isProd) { -// guildMessageEvent.getChannel().sendMessage("```mathematica\n" + t + "```").queue(); -// } else { -// StringWriter sw = new StringWriter(); -// PrintWriter pw = new PrintWriter(sw); -// t.printStackTrace(pw); -// guildMessageEvent.getChannel().sendMessage("```mathematica\n" + sw.toString() + "```").queue(); -// System.err.println("Error caught in: " + t.toString()); -// t.printStackTrace(); -// } -// } -// }); -// } -// } -} \ No newline at end of file diff --git a/src/pkg/deepCurse/nopalmo/manager/StatusManager.java b/src/pkg/deepCurse/nopalmo/manager/StatusManager.java index 310d8e1..32964bd 100644 --- a/src/pkg/deepCurse/nopalmo/manager/StatusManager.java +++ b/src/pkg/deepCurse/nopalmo/manager/StatusManager.java @@ -18,7 +18,7 @@ public class StatusManager { activityList.add(Activity.watching("my lead developer eat a watermelon whole")); activityList.add(Activity.watching( Boot.bot.getUserCache().asList().size() + " users in " + Boot.bot.getGuilds().size() + " servers")); - activityList.add(Activity.watching("for " + Global.prefix+ "help")); + activityList.add(Activity.watching("for " + Global.prefix + "help")); activityList.add(Activity.competing("your mothers love")); }