sync for kigu
Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
parent
749bd590bc
commit
2b59133f15
7 changed files with 118 additions and 57 deletions
|
@ -38,13 +38,15 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
|||
public default String getUsage(boolean hasPermissionInfo) {
|
||||
|
||||
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);
|
||||
if (getArguments() != null) {
|
||||
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.getArgName() + (i.isRequired() ? "> " : "] "));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +67,8 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
|||
}
|
||||
|
||||
@Override
|
||||
public default void runDirectCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
||||
public default void runPrivateCommand(CommandBlob blob, HashMap<String, Argument> argumentMap)
|
||||
throws Exception {
|
||||
runDualCommand(blob, argumentMap);
|
||||
}
|
||||
|
||||
|
@ -74,7 +77,7 @@ public interface CommandInterface { // TODO rewrite to implement type args?
|
|||
}
|
||||
|
||||
public interface PrivateCommandInterface extends CommandInterface {
|
||||
public void runDirectCommand(CommandBlob blob, HashMap<String, Argument> argumentList) throws Exception;
|
||||
public void runPrivateCommand(CommandBlob blob, HashMap<String, Argument> argumentList) throws Exception;
|
||||
}
|
||||
|
||||
public interface GuildCommandInterface extends CommandInterface {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package pkg.deepCurse.nopalmo.command.commands.general;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import pkg.deepCurse.nopalmo.command.CommandInterface.DualCommandInterface;
|
||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||
|
||||
public class Example implements DualCommandInterface {
|
||||
|
||||
@Override
|
||||
public String[] getCommandCalls() {
|
||||
return new String[] { "owo" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public HelpPage getHelpPage() {
|
||||
return HelpPage.General;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "an example command";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runDualCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
||||
|
||||
blob.getChannel().sendMessage("owo").queue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Argument> getArguments() {
|
||||
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
||||
|
||||
args.put("k", new Argument("k", (CommandBlob blob) -> {
|
||||
blob.getChannel().sendMessage("Dr. K").queue();
|
||||
}).setPrefixRequirement(true).setAutoStartRunnable(true));
|
||||
|
||||
return args;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ public class Info implements GuildCommandInterface, PrivateCommandInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void runDirectCommand(CommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
||||
public void runPrivateCommand(CommandBlob blob, HashMap<String, Argument> argumentList) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package pkg.deepCurse.nopalmo.command.commands.testing;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import pkg.deepCurse.nopalmo.command.CommandInterface.GuildCommandInterface;
|
||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||
|
||||
public class GuildCommand implements GuildCommandInterface {
|
||||
|
||||
@Override
|
||||
public String[] getCommandCalls() {
|
||||
return new String[] { "guild" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public HelpPage getHelpPage() {
|
||||
return HelpPage.TESTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "an example guild command";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runGuildCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
||||
|
||||
blob.getChannel().sendMessage("Message sent via command").queue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Argument> getArguments() {
|
||||
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
||||
|
||||
args.put("arg", new Argument("arg", (CommandBlob blob) -> {
|
||||
blob.getChannel().sendMessage("message sent via argument runnable").queue();
|
||||
}).setPrefixRequirement(true).setAutoStartRunnable(true));
|
||||
|
||||
return args;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package pkg.deepCurse.nopalmo.command.commands.testing;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import pkg.deepCurse.nopalmo.command.CommandInterface.PrivateCommandInterface;
|
||||
import pkg.deepCurse.nopalmo.manager.Argument;
|
||||
import pkg.deepCurse.nopalmo.manager.CommandBlob;
|
||||
|
||||
public class PrivateCommand implements PrivateCommandInterface {
|
||||
|
||||
@Override
|
||||
public String[] getCommandCalls() {
|
||||
return new String[] { "private" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public HelpPage getHelpPage() {
|
||||
return HelpPage.TESTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "an example private command";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runPrivateCommand(CommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
|
||||
blob.getChannel().sendMessage("Message sent via command").queue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Argument> getArguments() {
|
||||
HashMap<String, Argument> args = new HashMap<String, Argument>();
|
||||
|
||||
args.put("arg", new Argument("arg", (CommandBlob blob) -> {
|
||||
blob.getChannel().sendMessage("message sent via argument runnable").queue();
|
||||
}).setPrefixRequirement(true).setAutoStartRunnable(true));
|
||||
|
||||
return args;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -18,13 +18,14 @@ import pkg.deepCurse.nopalmo.command.CommandInterface;
|
|||
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;
|
||||
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.testing.GuildCommand;
|
||||
import pkg.deepCurse.nopalmo.command.commands.testing.PrivateCommand;
|
||||
import pkg.deepCurse.nopalmo.core.Boot;
|
||||
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
||||
|
@ -50,7 +51,8 @@ public class CommandManager {
|
|||
addCommand(new Prefix()); // guild
|
||||
addCommand(new Test()); // guild
|
||||
addCommand(new Info()); // guild direct
|
||||
addCommand(new Example()); // dual
|
||||
addCommand(new GuildCommand()); // guild
|
||||
addCommand(new PrivateCommand());
|
||||
}
|
||||
|
||||
private void addCommand(CommandInterface c) {
|
||||
|
@ -256,7 +258,19 @@ public class CommandManager {
|
|||
} else if (command instanceof GuildCommandInterface && event.isFromGuild()) {
|
||||
((GuildCommandInterface) command).runGuildCommand(commandBlob, argumentList);
|
||||
} else if (command instanceof PrivateCommandInterface && !event.isFromGuild()) {
|
||||
((PrivateCommandInterface) command).runDirectCommand(commandBlob, argumentList);
|
||||
((PrivateCommandInterface) command).runPrivateCommand(commandBlob, argumentList);
|
||||
}
|
||||
|
||||
if (command instanceof GuildCommandInterface && !event.isFromGuild()) {
|
||||
event.getChannel()
|
||||
.sendMessage(
|
||||
"Sorry, but you need to be in a "
|
||||
+ (DatabaseTools.Tools.Users.isAdvancedUser(
|
||||
commandBlob.getAuthorID()) ? "guild" : "server")
|
||||
+ " to use this command. . .")
|
||||
.queue();
|
||||
} else if (command instanceof PrivateCommandInterface && event.isFromGuild()) {
|
||||
event.getChannel().sendMessage("Sorry, but this command will only run in dms. . .").queue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ public class StatusManager {
|
|||
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"));
|
||||
// activityList.add(EntityBuilder.createActivity("owo", null, ActivityType.CUSTOM_STATUS));
|
||||
}
|
||||
|
||||
public static void shuffle(JDA bot) {
|
||||
|
|
Loading…
Add table
Reference in a new issue