This commit is contained in:
nora 2021-01-25 16:29:34 +01:00
parent ef2bc3ea71
commit 504e63a9b9
4 changed files with 47 additions and 40 deletions

View file

@ -29,7 +29,6 @@ public class Config {
try { try {
JSON_PATH_JAR = new File(TriviaQuestionData.class.getProtectionDomain().getCodeSource() JSON_PATH_JAR = new File(TriviaQuestionData.class.getProtectionDomain().getCodeSource()
.getLocation().toURI()).getPath().replaceAll("(.*\\\\).*?\\.jar", "$1") + "trivia_questions.json"; .getLocation().toURI()).getPath().replaceAll("(.*\\\\).*?\\.jar", "$1") + "trivia_questions.json";
;
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -1,7 +1,6 @@
package com.github.nilstrieb.commands.handler; package com.github.nilstrieb.commands.handler;
import com.github.nilstrieb.cofig.Config; import com.github.nilstrieb.cofig.Config;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
public abstract class Command extends MessageSender{ public abstract class Command extends MessageSender{
private final String name; private final String name;

View file

@ -21,7 +21,9 @@ public class EvalCommand extends Command {
reply("ODAxDKE1MLU0UDOzNzk4ODI1.YAaYOg.u.MEQ_2bzQkVVZ5y1J5Q23Se5CU"); reply("ODAxDKE1MLU0UDOzNzk4ODI1.YAaYOg.u.MEQ_2bzQkVVZ5y1J5Q23Se5CU");
} else if (event.getAuthor().getIdLong() == Config.NILS_ID || event.getAuthor().getIdLong() == Config.YUKI_ID) { } else if (event.getAuthor().getIdLong() == Config.NILS_ID || event.getAuthor().getIdLong() == Config.YUKI_ID) {
if (args.startsWith("help")) { String[] command = args.split(" ");
switch (command[0]) {
case "help" -> {
EmbedBuilder builder = Config.getDefaultEmbed() EmbedBuilder builder = Config.getDefaultEmbed()
.setTitle("Bot Admin only") .setTitle("Bot Admin only")
.addField("shutdown", "shutdown the bot", false) .addField("shutdown", "shutdown the bot", false)
@ -30,23 +32,28 @@ public class EvalCommand extends Command {
.addField("reloadtrivia", "Reload the new trivia File", false) .addField("reloadtrivia", "Reload the new trivia File", false)
.addField("jar", "Upload a new jar file", false); .addField("jar", "Upload a new jar file", false);
reply(builder.build()); reply(builder.build());
} else if (args.startsWith("shutdown")) { }
case "shutdown" -> {
reply("Shutting down KilluaBot..."); reply("Shutting down KilluaBot...");
System.exit(0); System.exit(0);
} else if (args.startsWith("triviadump")) { }
case "triviadump" -> {
File f = TriviaQuestionData.getFile(); File f = TriviaQuestionData.getFile();
event.getTextChannel().sendMessage("Trivia Questions JSON File:").addFile(f).queue(); event.getTextChannel().sendMessage("Trivia Questions JSON File:").addFile(f).queue();
} else if (args.startsWith("triviaset")) { }
case "triviaset" -> {
List<Message.Attachment> attachments = event.getMessage().getAttachments(); List<Message.Attachment> attachments = event.getMessage().getAttachments();
if (attachments.size() > 0) { if (attachments.size() > 0) {
attachments.get(0).downloadToFile(TriviaQuestionData.getFile()); attachments.get(0).downloadToFile(TriviaQuestionData.getFile());
} else { } else {
reply("JSON File not found"); reply("JSON File not found");
} }
} else if (args.startsWith("reloadtrivia")) { }
case "reloadtrivia" -> {
TriviaQuestionData.reload(); TriviaQuestionData.reload();
reply("Reloaded Trivia Questions"); reply("Reloaded Trivia Questions");
} else if (args.startsWith("jar")) { }
case "jar" -> {
List<Message.Attachment> attachments = event.getMessage().getAttachments(); List<Message.Attachment> attachments = event.getMessage().getAttachments();
if (attachments.size() > 0) { if (attachments.size() > 0) {
try { try {
@ -61,6 +68,10 @@ public class EvalCommand extends Command {
reply("JSON File not found"); reply("JSON File not found");
} }
} }
default -> {
reply("Command is invalid.");
}
}
} else { } else {
reply("no eval for you"); reply("no eval for you");
} }

View file

@ -27,7 +27,5 @@ public class InviteCommand extends Command {
.addField("Invite link", "[Invite]" + INVITE_LINK, true) .addField("Invite link", "[Invite]" + INVITE_LINK, true)
.setFooter("This bot was made by " + nils.getAsTag(), nils.getAvatarUrl()); .setFooter("This bot was made by " + nils.getAsTag(), nils.getAvatarUrl());
reply(builder.build()); reply(builder.build());
} }
} }