patches to command manager(and elsewhere) and added info command
Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
parent
744e678a1e
commit
0fddf1e458
15 changed files with 475 additions and 132 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
/bin/
|
/bin/
|
||||||
/src/pkg/deepCurse/nopalmo/core/TokenVault.java
|
/nopalmo.lock
|
||||||
|
|
|
@ -23,9 +23,10 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public default boolean isPremium() { // im probably never gonna use this, but ill leave it in for those who want to
|
public default int getPremiumLevel() { // im probably never gonna use this, but ill leave it in for those who want
|
||||||
|
// to
|
||||||
// see how i would implement it
|
// see how i would implement it
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract HelpPage getHelpPage();
|
public abstract HelpPage getHelpPage();
|
||||||
|
@ -36,8 +37,20 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
||||||
|
|
||||||
public String getHelp();
|
public String getHelp();
|
||||||
|
|
||||||
public default String getUsage() {
|
public default String getUsage(boolean hasPermissionInfo) {
|
||||||
return Global.prefix + getCommandName();
|
|
||||||
|
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() ? "> " : "] "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Global.prefix + getCommandName() + " " + sB.toString()).strip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public default int getTimeout() {
|
public default int getTimeout() {
|
||||||
|
@ -45,9 +58,7 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public default HashMap<String, Argument> getArguments() {
|
public HashMap<String, Argument> getArguments();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface DualCommandInterface extends DirectCommandInterface, GuildCommandInterface {
|
public interface DualCommandInterface extends DirectCommandInterface, GuildCommandInterface {
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,8 +93,4 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public default String getCompleteUsage() {
|
|
||||||
return Global.prefix + getCommandName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Guild;
|
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.Argument;
|
||||||
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ public class Prefix implements GuildCommandInterface {
|
||||||
Guild.Prefix.setPrefix(
|
Guild.Prefix.setPrefix(
|
||||||
blob.getEvent().getGuild().getIdLong(), argumentList.get("prefix").getWildCardString());
|
blob.getEvent().getGuild().getIdLong(), argumentList.get("prefix").getWildCardString());
|
||||||
blob.getEvent().getChannel().sendMessage("Set prefix to " + argumentList.get("prefix").getWildCardString()).queue();
|
blob.getEvent().getChannel().sendMessage("Set prefix to " + argumentList.get("prefix").getWildCardString()).queue();
|
||||||
blob.getChannel().sendMessage("Remember: you can always ping me to use any command in case you forget the prefix").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();
|
||||||
} else {
|
} else {
|
||||||
Guild.Prefix.setPrefix(
|
Guild.Prefix.setPrefix(
|
||||||
blob.getEvent().getGuild().getIdLong(), Global.prefix);
|
blob.getEvent().getGuild().getIdLong(), Global.prefix);
|
||||||
|
@ -45,11 +46,6 @@ public class Prefix implements GuildCommandInterface {
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage() {
|
|
||||||
return Global.prefix + getCommandName() + " <prefix>";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Sets a prefix for your guild";
|
return "Sets a prefix for your guild";
|
||||||
|
|
|
@ -2,6 +2,8 @@ package pkg.deepCurse.nopalmo.command.commands.general;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
||||||
|
@ -23,9 +25,24 @@ public class Test implements GuildCommandInterface {
|
||||||
return "A command used to test various things";
|
return "A command used to test various things";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNSFW() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPremiumLevel() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runGuildCommand(GuildCommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
public void runGuildCommand(GuildCommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
||||||
blob.getEvent().getChannel().sendMessage("Tested").queue();
|
blob.getEvent().getChannel().sendMessage("Tested").queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable HashMap<String, Argument> getArguments() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package pkg.deepCurse.nopalmo.command.commands.info;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
|
||||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ public class Git implements DualCommandInterface {
|
||||||
|
|
||||||
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));
|
}).setPrefixRequirement(true).setAutoStartRunnable(true).setDeveloper(true));
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +41,4 @@ public class Git implements DualCommandInterface {
|
||||||
return "Posts my github link";
|
return "Posts my github link";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCompleteUsage() {
|
|
||||||
return Global.prefix + getCommandName() + " [-test]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,7 @@ import java.util.List;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
||||||
import pkg.deepCurse.nopalmo.global.Tools;
|
|
||||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
|
||||||
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
||||||
import pkg.deepCurse.nopalmo.manager.GuildCommandManager;
|
import pkg.deepCurse.nopalmo.manager.GuildCommandManager;
|
||||||
|
|
||||||
|
@ -32,8 +30,6 @@ public class Help implements GuildCommandInterface {
|
||||||
deniedPages.add(HelpPage.EGG);
|
deniedPages.add(HelpPage.EGG);
|
||||||
deniedPages.add(HelpPage.TESTING);
|
deniedPages.add(HelpPage.TESTING);
|
||||||
|
|
||||||
// System.out.println(argumentMap.size()+":"+devEnabled+"\n"+argumentMap.toString());
|
|
||||||
|
|
||||||
if (argumentMap.isEmpty() || (isDevEnabled && argumentMap.size() == 1)) {
|
if (argumentMap.isEmpty() || (isDevEnabled && argumentMap.size() == 1)) {
|
||||||
EmbedBuilder embed = new EmbedBuilder().setTitle(isDevEnabled ? "^Commands:" : "Commands:");
|
EmbedBuilder embed = new EmbedBuilder().setTitle(isDevEnabled ? "^Commands:" : "Commands:");
|
||||||
|
|
||||||
|
@ -75,32 +71,25 @@ public class Help implements GuildCommandInterface {
|
||||||
|
|
||||||
GuildCommandInterface ping = blob.getCommandManager().getCommand("ping");
|
GuildCommandInterface ping = blob.getCommandManager().getCommand("ping");
|
||||||
if (ping != null) {
|
if (ping != null) {
|
||||||
sB.append("`" + ping.getUsage() + "`\n");
|
sB.append("`" + ping.getUsage(isDevEnabled) + "`\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildCommandInterface help = blob.getCommandManager().getCommand("help");
|
GuildCommandInterface info = blob.getCommandManager().getCommand("info");
|
||||||
if (help != null) {
|
if (info != null) {
|
||||||
sB.append("`" + help.getUsage() + "`\n");
|
sB.append("`" + info.getUsage(isDevEnabled) + "`\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildCommandInterface prefix = blob.getCommandManager().getCommand("prefix");
|
GuildCommandInterface prefix = blob.getCommandManager().getCommand("prefix");
|
||||||
if (prefix != null) {
|
if (prefix != null) {
|
||||||
sB.append("`" + prefix.getUsage() + "`\n");
|
sB.append("`" + prefix.getUsage(isDevEnabled) + "`\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.addField("Information:", "Commands to take note of:\n" + sB, false);
|
embed.addField("Information:", "Commands to take note of:\n" + sB, false);
|
||||||
|
|
||||||
// embed.addField("Commands : ", "`"+sB.toString()+"`\n", true);
|
|
||||||
// desc.append("`").append(sB).append("`\n");
|
|
||||||
|
|
||||||
// embed.addBlankField(true);
|
|
||||||
// embed.setFooter("Command list requested by: "+event.getAuthor().getAsTag(),
|
|
||||||
// event.getAuthor().getEffectiveAvatarUrl());
|
|
||||||
|
|
||||||
embed.setFooter(blob.getEvent().getMember().getEffectiveName(),
|
embed.setFooter(blob.getEvent().getMember().getEffectiveName(),
|
||||||
blob.getEvent().getMember().getUser().getEffectiveAvatarUrl());
|
blob.getEvent().getMember().getUser().getEffectiveAvatarUrl());
|
||||||
embed.setTimestamp(Instant.now());
|
embed.setTimestamp(Instant.now());
|
||||||
embed.setColor(0);
|
embed.setColor(Global.getEmbedColor());
|
||||||
|
|
||||||
blob.getChannel().sendMessageEmbeds(embed.build()).queue();
|
blob.getChannel().sendMessageEmbeds(embed.build()).queue();
|
||||||
|
|
||||||
|
@ -111,10 +100,10 @@ public class Help implements GuildCommandInterface {
|
||||||
|
|
||||||
if (command != null && ((deniedPages.contains(command.getHelpPage()) && isDevEnabled)
|
if (command != null && ((deniedPages.contains(command.getHelpPage()) && isDevEnabled)
|
||||||
|| !deniedPages.contains(command.getHelpPage()))) {
|
|| !deniedPages.contains(command.getHelpPage()))) {
|
||||||
if (!command.isNSFW()) {
|
if (!(command.isNSFW() && !blob.getChannel().isNSFW())) {
|
||||||
EmbedBuilder eB = new EmbedBuilder();
|
EmbedBuilder eB = new EmbedBuilder();
|
||||||
|
|
||||||
eB.setColor(0);
|
eB.setColor(Global.getEmbedColor());
|
||||||
StringBuilder sB = new StringBuilder();
|
StringBuilder sB = new StringBuilder();
|
||||||
|
|
||||||
eB.setTitle("Help results for: " + command.getCommandName());
|
eB.setTitle("Help results for: " + command.getCommandName());
|
||||||
|
@ -124,19 +113,24 @@ public class Help implements GuildCommandInterface {
|
||||||
eB.addField("Help info:", "This command does not contain help information", false);
|
eB.addField("Help info:", "This command does not contain help information", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
eB.addField("Usage:", command.getUsage(), false);
|
eB.addField("Usage:", "`" + command.getUsage(isDevEnabled) + "`", false);
|
||||||
|
|
||||||
eB.setFooter("Page: " + command.getHelpPage().toString());
|
eB.addField("Page:", command.getHelpPage().toString(), true); // ("Page: " +
|
||||||
|
// command.getHelpPage().toString());
|
||||||
|
eB.setFooter(blob.getEvent().getMember().getEffectiveName(),
|
||||||
|
blob.getEvent().getMember().getUser().getEffectiveAvatarUrl());
|
||||||
|
eB.setTimestamp(Instant.now());
|
||||||
|
|
||||||
if (command.getCommandCalls().length > 1) {
|
if (command.getCommandCalls().length > 1) {
|
||||||
|
sB.append("Aliases: ");
|
||||||
for (int i = 1; i < command.getCommandCalls().length; i++) {
|
for (int i = 1; i < command.getCommandCalls().length; i++) {
|
||||||
sB.append("`"+command.getCommandCalls()[i]+"` ");
|
sB.append("`" + command.getCommandCalls()[i] + "` ");
|
||||||
}
|
}
|
||||||
sB.append("\n");
|
sB.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.isNSFW()) {
|
if (command.isNSFW()) {
|
||||||
sB.append("Is nsfw: "+command.isNSFW());
|
sB.append("Is nsfw: " + command.isNSFW() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.getRequiredPermission() != null) {
|
if (command.getRequiredPermission() != null) {
|
||||||
|
@ -147,11 +141,16 @@ public class Help implements GuildCommandInterface {
|
||||||
sB.append("Usage Timeout: " + command.getTimeout() + "\n");
|
sB.append("Usage Timeout: " + command.getTimeout() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sB.append("Premium: " + command.isPremium() + "\n");
|
sB.append(
|
||||||
|
"Premium: " + ((command.getPremiumLevel() < 1) ? "no" : command.getPremiumLevel()) + "\n");
|
||||||
|
if (!sB.isEmpty()) {
|
||||||
eB.addField("Misc", sB.toString(), false);
|
eB.addField("Misc", sB.toString(), false);
|
||||||
|
}
|
||||||
blob.getChannel().sendMessageEmbeds(eB.build()).queue();
|
blob.getChannel().sendMessageEmbeds(eB.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
blob.getChannel().sendMessage("Sorry, but you are not allowed to view information about that command here, try somewhere more private").queue();
|
blob.getChannel().sendMessage(
|
||||||
|
"Sorry, but you are not allowed to view information about that command here, try somewhere more private")
|
||||||
|
.queue();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Tools.wrongUsage(blob.getChannel(), command);
|
// Tools.wrongUsage(blob.getChannel(), command);
|
||||||
|
@ -180,16 +179,6 @@ public class Help implements GuildCommandInterface {
|
||||||
return "The help command, it seems like you already know how to use it. . .";
|
return "The help command, it seems like you already know how to use it. . .";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage() {
|
|
||||||
return Global.prefix + getCommandCalls()[0] + " [Command name]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCompleteUsage() {
|
|
||||||
return Global.prefix + getCommandCalls()[0] + " [Command name | -dev]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, Argument> getArguments() {
|
public HashMap<String, Argument> getArguments() {
|
||||||
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
||||||
|
|
52
src/pkg/deepCurse/nopalmo/command/commands/info/Info.java
Normal file
52
src/pkg/deepCurse/nopalmo/command/commands/info/Info.java
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
package pkg.deepCurse.nopalmo.command.commands.info;
|
||||||
|
|
||||||
|
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.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 {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getCommandCalls() {
|
||||||
|
return new String[] { "info", "i" };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HelpPage getHelpPage() {
|
||||||
|
return HelpPage.Info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return "A command for getting information in and out of the bot";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable HashMap<String, Argument> getArguments() {
|
||||||
|
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
||||||
|
|
||||||
|
args.put("userdump", new Argument("userdump", (CommandBlob blob) -> {
|
||||||
|
blob.getChannel().sendMessage(Users.dump(blob.getUserID())).queue();
|
||||||
|
}).setPrefixRequirement(true).setAutoStartRunnable(true)
|
||||||
|
.setSkipOriginalTaskOnRunnable(true));
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runDirectCommand(DirectCommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runGuildCommand(GuildCommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
||||||
|
blob.getChannel().sendMessage("EEE").queue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
|
||||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||||
import pkg.deepCurse.nopalmo.utils.UptimePing;
|
import pkg.deepCurse.nopalmo.utils.UptimePing;
|
||||||
|
@ -57,11 +56,6 @@ public class Ping implements DualCommandInterface {
|
||||||
return new String[] { "ping" };
|
return new String[] { "ping" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage() {
|
|
||||||
return Global.prefix + getCommandName()+" [" + Argument.argumentPrefix + "all]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HelpPage getHelpPage() {
|
public HelpPage getHelpPage() {
|
||||||
return HelpPage.Info;
|
return HelpPage.Info;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import pkg.deepCurse.nopalmo.listener.DirectMessageReceivedListener;
|
||||||
import pkg.deepCurse.nopalmo.listener.GuildMessageReceivedListener;
|
import pkg.deepCurse.nopalmo.listener.GuildMessageReceivedListener;
|
||||||
import pkg.deepCurse.nopalmo.manager.DirectCommandManager;
|
import pkg.deepCurse.nopalmo.manager.DirectCommandManager;
|
||||||
import pkg.deepCurse.nopalmo.manager.GuildCommandManager;
|
import pkg.deepCurse.nopalmo.manager.GuildCommandManager;
|
||||||
|
import pkg.deepCurse.nopalmo.manager.StatusManager;
|
||||||
import pkg.deepCurse.nopalmo.utils.Locks;
|
import pkg.deepCurse.nopalmo.utils.Locks;
|
||||||
import pkg.deepCurse.nopalmo.utils.LogHelper;
|
import pkg.deepCurse.nopalmo.utils.LogHelper;
|
||||||
|
|
||||||
|
@ -37,6 +38,16 @@ public class Boot {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LogHelper.boot("Booting: <" + pid + ">");
|
LogHelper.boot("Booting: <" + pid + ">");
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
long count = 0;
|
||||||
|
while (true) {
|
||||||
|
if (count++ > 1000000000) {
|
||||||
|
count = 0;
|
||||||
|
System.out.println("owo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "owo");
|
||||||
|
|
||||||
LogHelper.boot("Testing Lock. . .");
|
LogHelper.boot("Testing Lock. . .");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -108,7 +119,7 @@ public class Boot {
|
||||||
|
|
||||||
.setEnableShutdownHook(true)
|
.setEnableShutdownHook(true)
|
||||||
|
|
||||||
.build();
|
.build().awaitReady();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.crash(e);
|
LogHelper.crash(e);
|
||||||
|
@ -117,12 +128,16 @@ public class Boot {
|
||||||
bot.getPresence().setStatus(OnlineStatus.ONLINE);
|
bot.getPresence().setStatus(OnlineStatus.ONLINE);
|
||||||
bot.getPresence().setActivity(Activity.listening("Infected Mushroom"));
|
bot.getPresence().setActivity(Activity.listening("Infected Mushroom"));
|
||||||
|
|
||||||
|
LogHelper.boot("Init status list");
|
||||||
|
StatusManager.init();
|
||||||
|
LogHelper.boot("Initialized status list. . .");
|
||||||
|
|
||||||
long bootTime = System.currentTimeMillis() - preBootTime;
|
long bootTime = System.currentTimeMillis() - preBootTime;
|
||||||
|
|
||||||
LogHelper.boot("Taken " + bootTime + "ms to boot");
|
LogHelper.boot("Taken " + bootTime + "ms to boot");
|
||||||
|
|
||||||
// LogHelper.boot("Starting loop");
|
LogHelper.boot("Starting loop");
|
||||||
// loop();
|
loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loop() {
|
private static void loop() {
|
||||||
|
@ -132,36 +147,40 @@ public class Boot {
|
||||||
long fiveMins = lastTime;
|
long fiveMins = lastTime;
|
||||||
long threeMins = lastTime;
|
long threeMins = lastTime;
|
||||||
long lastTimeUpdateStatus = lastTime;
|
long lastTimeUpdateStatus = lastTime;
|
||||||
long lastTimeCheckUpdate= lastTime;
|
long lastTimeCheckUpdate = lastTime;
|
||||||
|
|
||||||
long dynamicWait = 0;
|
long dynamicWait = Global.getDynamicWait();
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
if (now > lastTime + dynamicWait) { // dynamic wait loop
|
if (now > lastTime + dynamicWait) { // dynamic wait loop
|
||||||
|
lastTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now > lastTimeCheckUpdate + 900000) {
|
if (now > lastTimeCheckUpdate + 900000) {
|
||||||
|
lastTimeCheckUpdate = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now > lastTimeUpdateStatus + dynamicWait && Global.isShuffleStatusEnabled()) {
|
if (now > lastTimeUpdateStatus + dynamicWait && Global.isShuffleStatusEnabled()) {
|
||||||
|
lastTimeUpdateStatus = now;
|
||||||
|
|
||||||
|
StatusManager.shuffle(bot);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now > fifteenMins + 900000) {
|
if (now > fifteenMins + 900000) {
|
||||||
|
fifteenMins = now;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now > fiveMins + 300000) {
|
if (now > fiveMins + 300000) {
|
||||||
|
fiveMins = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now > threeMins + 180000) {
|
if (now > threeMins + 180000) {
|
||||||
|
threeMins = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.ResultSetMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
@ -57,6 +58,89 @@ public class DatabaseTools {
|
||||||
// these sub classes will represent tables and the methods therein will be for
|
// these sub classes will represent tables and the methods therein will be for
|
||||||
// actions within said table
|
// actions within said table
|
||||||
|
|
||||||
|
public class Users {
|
||||||
|
|
||||||
|
public static int getPremiumLevel(long userID) {
|
||||||
|
Statement st = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String query = "select * from users where userid = " + userID;
|
||||||
|
try {
|
||||||
|
st = connection.createStatement();
|
||||||
|
rs = st.executeQuery(query);
|
||||||
|
if (rs.next()) {
|
||||||
|
return rs.getInt("premiumlevel");
|
||||||
|
} else {
|
||||||
|
// throw new SQLException(null, null, 33); // we need a real catcher here
|
||||||
|
System.err
|
||||||
|
.println("Failed to execute; errorCode=NO_ROW_FOUND; No row found; On action " + query);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SQLCode.getMessage(query, e.getErrorCode());
|
||||||
|
return 0;
|
||||||
|
} finally { // @formatter:off
|
||||||
|
try {if (rs != null)rs.close();} catch (Exception e) {}
|
||||||
|
try {if (st != null)st.close();} catch (Exception e) {}
|
||||||
|
// @formatter:on
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAdvancedUser(long userID) {
|
||||||
|
Statement st = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String query = "select * from users where userid = " + userID;
|
||||||
|
try {
|
||||||
|
st = connection.createStatement();
|
||||||
|
rs = st.executeQuery(query);
|
||||||
|
if (rs.next()) {
|
||||||
|
return rs.getBoolean("advanceduser");
|
||||||
|
} else {
|
||||||
|
// throw new SQLException(null, null, 33); // we need a real catcher here
|
||||||
|
System.err
|
||||||
|
.println("Failed to execute; errorCode=NO_ROW_FOUND; No row found; On action " + query);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SQLCode.getMessage(query, e.getErrorCode());
|
||||||
|
return false;
|
||||||
|
} finally { // @formatter:off
|
||||||
|
try {if (rs != null)rs.close();} catch (Exception e) {}
|
||||||
|
try {if (st != null)st.close();} catch (Exception e) {}
|
||||||
|
// @formatter:on
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String dump(long userID) {
|
||||||
|
Statement st = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String query = "select * from users where userid = " + userID;
|
||||||
|
try {
|
||||||
|
st = connection.createStatement();
|
||||||
|
rs = st.executeQuery(query);
|
||||||
|
ResultSetMetaData rsMeta = rs.getMetaData();
|
||||||
|
int columnCount = rsMeta.getColumnCount();
|
||||||
|
StringBuilder sB = new StringBuilder();
|
||||||
|
while (rs.next()) {
|
||||||
|
// Object[] values = new Object[columnCount];
|
||||||
|
for (int i = 1; i <= columnCount; i++) {
|
||||||
|
// values[i - 1] = resultSet.getObject(i);
|
||||||
|
sB.append(rsMeta.getColumnLabel(i) + ": " + rs.getString(i) + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sB.toString();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SQLCode.getMessage(query, e.getErrorCode());
|
||||||
|
return null;
|
||||||
|
} finally { // @formatter:off
|
||||||
|
try {if (rs != null)rs.close();} catch (Exception e) {}
|
||||||
|
try {if (st != null)st.close();} catch (Exception e) {}
|
||||||
|
// @formatter:on
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class Guild {
|
public class Guild {
|
||||||
|
|
||||||
public class Prefix {
|
public class Prefix {
|
||||||
|
@ -296,10 +380,116 @@ public class DatabaseTools {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isShuffleStatusEnabled() {
|
public static boolean isShuffleStatusEnabled() {
|
||||||
|
Statement st = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String query = "select * from global where id = 'isshufflestatusenabled'";
|
||||||
|
try {
|
||||||
|
st = connection.createStatement();
|
||||||
|
rs = st.executeQuery(query);
|
||||||
|
if (rs.next()) {
|
||||||
|
return rs.getString("value").contentEquals("true");
|
||||||
|
} else {
|
||||||
|
System.err
|
||||||
|
.println("Failed to execute; errorCode=NO_ROW_FOUND; No row found; On action " + query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SQLCode.getMessage(query, e.getErrorCode());
|
||||||
|
// System.out.println("eeeeee");
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (rs != null)
|
||||||
|
rs.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (st != null)
|
||||||
|
st.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// try { if (conn != null) conn.close(); } catch (Exception e) {};
|
||||||
|
}
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDynamicWait() {
|
||||||
|
Statement st = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String query = "select * from global where id = 'dynamicwait'";
|
||||||
|
try {
|
||||||
|
st = connection.createStatement();
|
||||||
|
rs = st.executeQuery(query);
|
||||||
|
if (rs.next()) {
|
||||||
|
return rs.getInt("value");
|
||||||
|
} else {
|
||||||
|
System.err
|
||||||
|
.println("Failed to execute; errorCode=NO_ROW_FOUND; No row found; On action " + query);
|
||||||
|
return 45000;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SQLCode.getMessage(query, e.getErrorCode());
|
||||||
|
// System.out.println("eeeeee");
|
||||||
|
return 45000;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (rs != null)
|
||||||
|
rs.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (st != null)
|
||||||
|
st.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// try { if (conn != null) conn.close(); } catch (Exception e) {};
|
||||||
|
}
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEmbedColor() {
|
||||||
|
Statement st = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
String query = "select * from global where id = 'embedcolor'";
|
||||||
|
try {
|
||||||
|
st = connection.createStatement();
|
||||||
|
rs = st.executeQuery(query);
|
||||||
|
if (rs.next()) {
|
||||||
|
return rs.getInt("value");
|
||||||
|
} else {
|
||||||
|
System.err
|
||||||
|
.println("Failed to execute; errorCode=NO_ROW_FOUND; No row found; On action " + query);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SQLCode.getMessage(query, e.getErrorCode());
|
||||||
|
// System.out.println("eeeeee");
|
||||||
|
return 0;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (rs != null)
|
||||||
|
rs.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (st != null)
|
||||||
|
st.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// try { if (conn != null) conn.close(); } catch (Exception e) {};
|
||||||
|
}
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public class Reaction { // started off as a good idea but it sucks
|
// public class Reaction { // started off as a good idea but it sucks
|
||||||
|
|
|
@ -6,11 +6,11 @@ import pkg.deepCurse.nopalmo.command.CommandInterface;
|
||||||
public class Tools {
|
public class Tools {
|
||||||
|
|
||||||
public static void wrongUsage(MessageChannel messageChannel, CommandInterface command) {
|
public static void wrongUsage(MessageChannel messageChannel, CommandInterface command) {
|
||||||
messageChannel.sendMessage("Wrong Command Usage!\n" + command.getUsage()).queue();
|
messageChannel.sendMessage("Wrong Command Usage!\n" + command.getUsage(false)).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invalidPermissions(MessageChannel messageChannel, CommandInterface command) {
|
public static void invalidPermissions(MessageChannel messageChannel, CommandInterface command) {
|
||||||
messageChannel.sendMessage("Sorry, but you are not allowed to use that! Try this:\n" + command.getUsage()).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) {
|
// public static void wrongUsage(MessageChannel tc, DirectCommandInterface c) {
|
||||||
|
|
|
@ -21,13 +21,15 @@ public class Argument {
|
||||||
private String argName = null;
|
private String argName = null;
|
||||||
private Argument[] subArgs = null;
|
private Argument[] subArgs = null;
|
||||||
private boolean requiresPrefix = false;
|
private boolean requiresPrefix = false;
|
||||||
private Boolean isWildcard;
|
private Boolean isWildcard = false;
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
private String wildCardString = null;
|
private String wildCardString = null;
|
||||||
private boolean autoStartRunnable = false;
|
private boolean autoStartRunnable = false;
|
||||||
private boolean skipOriginalTaskOnRunnable = false;
|
private boolean skipOriginalTaskOnRunnable = false;
|
||||||
private RunnableArg runnableArg = null;
|
private RunnableArg runnableArg = null;
|
||||||
private String permissionLevel;
|
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
|
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
|
// generally not change, ever, its recommended you keep it to
|
||||||
|
@ -186,6 +188,7 @@ public class Argument {
|
||||||
|
|
||||||
public Argument setPermissionLevel(String string) {
|
public Argument setPermissionLevel(String string) {
|
||||||
this.permissionLevel = string;
|
this.permissionLevel = string;
|
||||||
|
this.isDeveloper = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,4 +196,22 @@ public class Argument {
|
||||||
return this.permissionLevel;
|
return this.permissionLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRequired() {
|
||||||
|
return this.isRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Argument setIsRequired(boolean bool) {
|
||||||
|
this.isRequired = bool;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDeveloper() {
|
||||||
|
return isDeveloper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Argument setDeveloper(boolean isDeveloper) {
|
||||||
|
this.isDeveloper = isDeveloper;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class DirectCommandManager extends CommandManager {
|
||||||
|
|
||||||
public DirectCommandManager() {
|
public DirectCommandManager() {
|
||||||
init();
|
init();
|
||||||
executor = Executors.newSingleThreadExecutor();
|
executor = Executors.newCachedThreadPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
|
@ -14,14 +14,15 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.general.Example;
|
|
||||||
import pkg.deepCurse.nopalmo.command.commands.general.Prefix;
|
import pkg.deepCurse.nopalmo.command.commands.general.Prefix;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.general.Test;
|
import pkg.deepCurse.nopalmo.command.commands.general.Test;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.info.Git;
|
import pkg.deepCurse.nopalmo.command.commands.info.Git;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.info.Help;
|
import pkg.deepCurse.nopalmo.command.commands.info.Help;
|
||||||
|
import pkg.deepCurse.nopalmo.command.commands.info.Info;
|
||||||
import pkg.deepCurse.nopalmo.command.commands.info.Ping;
|
import pkg.deepCurse.nopalmo.command.commands.info.Ping;
|
||||||
import pkg.deepCurse.nopalmo.core.Boot;
|
import pkg.deepCurse.nopalmo.core.Boot;
|
||||||
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
||||||
|
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Users;
|
||||||
import pkg.deepCurse.nopalmo.global.Tools;
|
import pkg.deepCurse.nopalmo.global.Tools;
|
||||||
|
|
||||||
public class GuildCommandManager extends CommandManager {
|
public class GuildCommandManager extends CommandManager {
|
||||||
|
@ -31,7 +32,7 @@ public class GuildCommandManager extends CommandManager {
|
||||||
|
|
||||||
public GuildCommandManager() {
|
public GuildCommandManager() {
|
||||||
init();
|
init();
|
||||||
executor = Executors.newSingleThreadExecutor();
|
executor = Executors.newWorkStealingPool();// newCachedThreadPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -40,7 +41,7 @@ public class GuildCommandManager extends CommandManager {
|
||||||
addCommand(new Git());
|
addCommand(new Git());
|
||||||
addCommand(new Prefix());
|
addCommand(new Prefix());
|
||||||
addCommand(new Test());
|
addCommand(new Test());
|
||||||
addCommand(new Example());
|
addCommand(new Info());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCommand(GuildCommandInterface c) {
|
private void addCommand(GuildCommandInterface c) {
|
||||||
|
@ -100,7 +101,6 @@ public class GuildCommandManager extends CommandManager {
|
||||||
boolean printTime = false;
|
boolean printTime = false;
|
||||||
byte argSkipCount = 0;
|
byte argSkipCount = 0;
|
||||||
boolean remainsValid = true;
|
boolean remainsValid = true;
|
||||||
// int id = 0;
|
|
||||||
|
|
||||||
HashMap<Integer, Argument> positionalArgs = new HashMap<Integer, Argument>();
|
HashMap<Integer, Argument> positionalArgs = new HashMap<Integer, Argument>();
|
||||||
|
|
||||||
|
@ -109,11 +109,6 @@ public class GuildCommandManager extends CommandManager {
|
||||||
if (i.getPosition() >= 0) {
|
if (i.getPosition() >= 0) {
|
||||||
positionalArgs.put(i.getPosition(), i);
|
positionalArgs.put(i.getPosition(), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.isSkipOriginalTaskOnRunnable()) {
|
|
||||||
remainsValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +149,9 @@ public class GuildCommandManager extends CommandManager {
|
||||||
if (guildCommand.getArguments().get(pre).getPermission() == null
|
if (guildCommand.getArguments().get(pre).getPermission() == null
|
||||||
|| DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(),
|
|| DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(),
|
||||||
guildCommand.getArguments().get(pre).getPermission())) {
|
guildCommand.getArguments().get(pre).getPermission())) {
|
||||||
|
if (guildCommand.getArguments().get(pre).isSkipOriginalTaskOnRunnable()) {
|
||||||
|
remainsValid = false;
|
||||||
|
}
|
||||||
argumentList.put(pre, guildCommand.getArguments().get(pre));
|
argumentList.put(pre, guildCommand.getArguments().get(pre));
|
||||||
if (guildCommand.getArguments().get(pre).isAutoStartRunnable()
|
if (guildCommand.getArguments().get(pre).isAutoStartRunnable()
|
||||||
&& guildCommand.getArguments().get(pre).getRunnableArg() != null) {
|
&& guildCommand.getArguments().get(pre).getRunnableArg() != null) {
|
||||||
|
@ -174,6 +172,9 @@ public class GuildCommandManager extends CommandManager {
|
||||||
if (guildCommand.getArguments().get(x).getPermission() == null
|
if (guildCommand.getArguments().get(x).getPermission() == null
|
||||||
|| DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(),
|
|| DatabaseTools.Tools.Developers.hasPermission(commandBlob.getUserID(),
|
||||||
guildCommand.getArguments().get(x).getPermission())) {
|
guildCommand.getArguments().get(x).getPermission())) {
|
||||||
|
if (guildCommand.getArguments().get(x).isSkipOriginalTaskOnRunnable()) {
|
||||||
|
remainsValid = false;
|
||||||
|
}
|
||||||
argumentList.put(x, guildCommand.getArguments().get(x));
|
argumentList.put(x, guildCommand.getArguments().get(x));
|
||||||
offset++;
|
offset++;
|
||||||
if (guildCommand.getArguments().get(x).isAutoStartRunnable()
|
if (guildCommand.getArguments().get(x).isAutoStartRunnable()
|
||||||
|
@ -191,6 +192,9 @@ public class GuildCommandManager extends CommandManager {
|
||||||
|| DatabaseTools.Tools.Developers.hasPermission(
|
|| DatabaseTools.Tools.Developers.hasPermission(
|
||||||
commandBlob.getUserID(),
|
commandBlob.getUserID(),
|
||||||
positionalArgs.get(i - offset).getPermission())) {
|
positionalArgs.get(i - offset).getPermission())) {
|
||||||
|
if (positionalArgs.get(i - offset).isSkipOriginalTaskOnRunnable()) {
|
||||||
|
remainsValid = false;
|
||||||
|
}
|
||||||
if (positionalArgs.get(i - offset).getIsWildcard()) {
|
if (positionalArgs.get(i - offset).getIsWildcard()) {
|
||||||
argumentList.put(positionalArgs.get(i - offset).getArgName(),
|
argumentList.put(positionalArgs.get(i - offset).getArgName(),
|
||||||
positionalArgs.get(i - offset).setWildCardString(x));
|
positionalArgs.get(i - offset).setWildCardString(x));
|
||||||
|
@ -220,6 +224,21 @@ public class GuildCommandManager extends CommandManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
commandBlob.setCommandManager(this);
|
||||||
|
|
||||||
if (remainsValid) {
|
if (remainsValid) {
|
||||||
|
|
45
src/pkg/deepCurse/nopalmo/manager/StatusManager.java
Normal file
45
src/pkg/deepCurse/nopalmo/manager/StatusManager.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package pkg.deepCurse.nopalmo.manager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
|
import pkg.deepCurse.nopalmo.core.Boot;
|
||||||
|
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
||||||
|
|
||||||
|
public class StatusManager {
|
||||||
|
|
||||||
|
private static List<Activity> activityList = new ArrayList<Activity>();
|
||||||
|
private static int selection = 0;
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
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.competing("your mothers love"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void shuffle(JDA bot) {
|
||||||
|
|
||||||
|
int rand = new Random().nextInt(activityList.size());
|
||||||
|
|
||||||
|
bot.getPresence().setActivity(activityList.get(rand));
|
||||||
|
selection = rand;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(JDA bot, int interger) {
|
||||||
|
|
||||||
|
bot.getPresence().setActivity(activityList.get(interger));
|
||||||
|
selection = interger;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void increment(JDA bot) {
|
||||||
|
bot.getPresence().setActivity(activityList.get(selection > activityList.size() ? selection = 0 : ++selection));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue