h
Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
parent
0c90d78b64
commit
f71abeb499
5 changed files with 71 additions and 64 deletions
|
@ -36,5 +36,25 @@ public abstract class GuildCommand {
|
|||
public enum HelpPage {
|
||||
General, DEV, EGG, Moderation, Fun, Info
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Permission getRequiredPermission() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,49 +1,46 @@
|
|||
package pkg.deepCurse.nopalmo.command.guildCommand.info;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import core.Global;
|
||||
import core.enums.HelpPage;
|
||||
import core.listeners.Command;
|
||||
import core.listeners.CommandManager;
|
||||
import core.tools.Tools;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import pkg.deepCurse.nopalmo.command.GuildCommand;
|
||||
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
|
||||
import pkg.deepCurse.nopalmo.global.Tools;
|
||||
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
|
||||
import pkg.deepCurse.nopalmo.manager.GuildCommandManager;
|
||||
|
||||
public class Help implements Command {
|
||||
public final CommandManager manager;
|
||||
public class Help extends GuildCommand {
|
||||
|
||||
public Help(CommandManager m) {
|
||||
public final GuildCommandManager manager;
|
||||
|
||||
public Help(GuildCommandManager m) {
|
||||
this.manager = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<String> args, GuildMessageReceivedEvent event, ArrayList<Long> devList) throws Exception {
|
||||
public void run(GuildCommandBlob blob, GuildCommandManager commandManager) throws Exception {
|
||||
// TextChannel channel = event.getChannel();
|
||||
// Member user = event.getMember();
|
||||
// if (Tools.devIdCheck(null, user.getId(), channel, null)) {
|
||||
if (args.size() > 1) {
|
||||
Tools.wrongUsage(event.getChannel(), this);
|
||||
if (blob.getArgs().size() > 1) {
|
||||
Tools.wrongUsage(blob.getGuildMessageEvent().getChannel(), this);
|
||||
return;
|
||||
}
|
||||
if (args.isEmpty()) {
|
||||
if (blob.getArgs().isEmpty()) {
|
||||
EmbedBuilder embed = new EmbedBuilder().setTitle("Commands:");
|
||||
|
||||
for (HelpPage i : HelpPage.values()) {
|
||||
if (i != HelpPage.DEV) {
|
||||
StringBuilder pageData = new StringBuilder();
|
||||
|
||||
for (Command command : manager.getCommands()) {
|
||||
if (!command.isHidden() & command.getPage() != HelpPage.EGG) {
|
||||
if (command.getPage() == i) {
|
||||
for (GuildCommand command : manager.getGuildCommands()) {
|
||||
if (!command.isHidden() & command.getHelpPage() != HelpPage.EGG) {
|
||||
if (command.getHelpPage() == i) {
|
||||
|
||||
if (!pageData.toString().contains(command.getName())) {
|
||||
pageData.append("`" + command.getName() + "`\n");
|
||||
if (!pageData.toString().contains(command.getCommandName())) {
|
||||
pageData.append("`" + command.getCommandName() + "`\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,45 +69,46 @@ public class Help implements Command {
|
|||
// embed.setFooter("Command list requested by: "+event.getAuthor().getAsTag(),
|
||||
// event.getAuthor().getEffectiveAvatarUrl());
|
||||
|
||||
embed.setFooter(event.getMember().getEffectiveName(), event.getMember().getUser().getEffectiveAvatarUrl());
|
||||
embed.setFooter(blob.getGuildMessageEvent().getMember().getEffectiveName(),
|
||||
blob.getGuildMessageEvent().getMember().getUser().getEffectiveAvatarUrl());
|
||||
embed.setTimestamp(Instant.now());
|
||||
embed.setColor(Global.embedColor);
|
||||
embed.setColor(0);
|
||||
if (embed.isValidLength()) {
|
||||
event.getChannel().sendMessage(embed.build()).queue();
|
||||
blob.getGuildMessageEvent().getChannel().sendMessage(embed.build()).queue();
|
||||
} else {
|
||||
event.getChannel()
|
||||
blob.getGuildMessageEvent().getChannel()
|
||||
.sendMessage(
|
||||
"Critical error!\nEmbed max size exceeded, please report this to the devs immediately")
|
||||
.queue();
|
||||
}
|
||||
if (new Random().nextLong() == 69420l) { // i wonder who will find this, also, if you read the source to
|
||||
// find this, shhhhhhhh - deepCurse
|
||||
event.getChannel().sendMessage("we will rise above you humans")
|
||||
blob.getGuildMessageEvent().getChannel().sendMessage("we will rise above you humans")
|
||||
.queue(msg -> msg.delete().queueAfter(300, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Command command = manager.getCommand(String.join("", args));
|
||||
GuildCommand command = manager.getCommand(String.join("", blob.getArgs()));
|
||||
|
||||
// event.getChannel().sendMessage("Command help for `" + command.commandName() +
|
||||
// "`:\n\tUsage: "+ command.usageString() + "\n" +
|
||||
// command.helpString()).queue();
|
||||
if (!command.isHidden() & command.getPage() != HelpPage.EGG) {
|
||||
if (!command.isHidden() & command.getHelpPage() != HelpPage.EGG) {
|
||||
EmbedBuilder eB = new EmbedBuilder();
|
||||
eB.setTitle("Help results for: " + command.getName());
|
||||
eB.setTitle("Help results for: " + command.getCommandName());
|
||||
if (command.getHelp() != null) {
|
||||
eB.addField("Help info:", command.getHelp(), false);
|
||||
}
|
||||
eB.addField("Usage:", command.getUsage(), false);
|
||||
eB.setFooter("Page: " + command.getPage().toString());
|
||||
eB.setFooter("Page: " + command.getHelpPage().toString());
|
||||
String alias = "`";
|
||||
for (int i = 1; i < command.getCalls().length; i++) {
|
||||
for (int i = 1; i < command.getCommandCalls().length; i++) {
|
||||
|
||||
if (i == 1) {
|
||||
alias += command.getCalls()[i];
|
||||
alias += command.getCommandCalls()[i];
|
||||
} else {
|
||||
alias += ", " + command.getCalls()[i];
|
||||
alias += ", " + command.getCommandCalls()[i];
|
||||
}
|
||||
}
|
||||
alias += "`";
|
||||
|
@ -122,26 +120,27 @@ public class Help implements Command {
|
|||
} else {
|
||||
endAilias = "Aliases: none\n";
|
||||
}
|
||||
eB.setColor(Global.embedColor);
|
||||
eB.setColor(0);
|
||||
StringBuilder sB = new StringBuilder();
|
||||
sB.append(endAilias);
|
||||
try {
|
||||
sB.append("Required Permission: " + command.getRequiredPermission().getName()+"\n");
|
||||
sB.append("Required Permission: " + command.getRequiredPermission().getName() + "\n");
|
||||
} catch (NullPointerException e) {
|
||||
}if(command.getTimeout()>0) {
|
||||
sB.append("Usage Timeout: "+command.getTimeout()+"\n");
|
||||
}
|
||||
sB.append("Premium: "+command.isPremium()+"\n");
|
||||
if (command.getTimeout() > 0) {
|
||||
sB.append("Usage Timeout: " + command.getTimeout() + "\n");
|
||||
}
|
||||
sB.append("Premium: " + command.isPremium() + "\n");
|
||||
eB.addField("Misc", sB.toString(), false);
|
||||
event.getChannel().sendMessage(eB.build()).queue();
|
||||
blob.getGuildMessageEvent().getChannel().sendMessage(eB.build()).queue();
|
||||
} else {
|
||||
throw new NullPointerException("Invalid input");
|
||||
}
|
||||
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
event.getChannel().sendMessage("The command `" + String.join("", args) + "` does not exist!\n" + "Use `"
|
||||
+ Global.Prefix + getCalls()[0] + "` for a list of all my commands!").queue();
|
||||
blob.getGuildMessageEvent().getChannel().sendMessage("The command `" + String.join("", blob.getArgs()) + "` does not exist!\n" + "Use `"
|
||||
+ Global.prefix + getCommandCalls()[0] + "` for a list of all my commands!").queue();
|
||||
return;
|
||||
|
||||
}
|
||||
|
@ -156,12 +155,12 @@ public class Help implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public HelpPage getPage() {
|
||||
public HelpPage getHelpPage() {
|
||||
return HelpPage.Info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCalls() {
|
||||
public String[] getCommandCalls() {
|
||||
|
||||
return new String[] { "help", "h" };
|
||||
}
|
||||
|
@ -172,25 +171,11 @@ public class Help implements Command {
|
|||
return "The help command, it seems like you already know how to use it. . .";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission getRequiredPermission() {
|
||||
return Permission.MESSAGE_WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getCalls()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return Global.Prefix + getCalls()[0] + " [Command name]";
|
||||
return Global.prefix + getCommandCalls()[0] + " [Command name]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPremium() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -43,9 +43,9 @@ public class Boot {
|
|||
Log.boot("Init reaction/emote list");
|
||||
Reactions.init();
|
||||
Log.boot("Initialized reaction/emote list. . .");
|
||||
Log.boot("Init commands list");
|
||||
Log.boot("Init guild commands list");
|
||||
guildCommandManager.init();
|
||||
Log.boot("Initialized commands list. . .");
|
||||
Log.boot("Initialized guild commands list. . .");
|
||||
|
||||
try {
|
||||
bot = JDABuilder.createDefault(args[0]).setChunkingFilter(ChunkingFilter.NONE)
|
||||
|
@ -57,7 +57,9 @@ public class Boot {
|
|||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
bot.getPresence().setActivity(Activity.listening("Infected Mushroom"));
|
||||
|
||||
long bootTime = System.currentTimeMillis() - preBootTime;
|
||||
|
||||
System.out.println("Taken "+bootTime+"ms to boot");
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import pkg.deepCurse.nopalmo.command.GuildCommand;
|
||||
import pkg.deepCurse.nopalmo.command.guildCommand.Ping;
|
||||
import pkg.deepCurse.nopalmo.command.guildCommand.info.Ping;
|
||||
import pkg.deepCurse.nopalmo.core.Boot;
|
||||
import pkg.deepCurse.nopalmo.database.DatabaseTools;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class GuildCommandManager {
|
|||
}
|
||||
}
|
||||
|
||||
public Collection<GuildCommand> getguildCommandMap() {
|
||||
public Collection<GuildCommand> getGuildCommands() {
|
||||
return guildCommandMap.values();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class UptimePing {
|
|||
|
||||
}
|
||||
|
||||
System.out.println("fix me");
|
||||
// System.out.println("fix me"); // not sure why this is here
|
||||
|
||||
if (socketAddress.getAddress() == null) {
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue