mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-14 15:15:01 +01:00
FIX
This commit is contained in:
parent
ef2bc3ea71
commit
504e63a9b9
4 changed files with 47 additions and 40 deletions
|
|
@ -29,7 +29,6 @@ public class Config {
|
|||
try {
|
||||
JSON_PATH_JAR = new File(TriviaQuestionData.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation().toURI()).getPath().replaceAll("(.*\\\\).*?\\.jar", "$1") + "trivia_questions.json";
|
||||
;
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.nilstrieb.commands.handler;
|
||||
|
||||
import com.github.nilstrieb.cofig.Config;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public abstract class Command extends MessageSender{
|
||||
private final String name;
|
||||
|
|
|
|||
|
|
@ -21,44 +21,55 @@ public class EvalCommand extends Command {
|
|||
reply("ODAxDKE1MLU0UDOzNzk4ODI1.YAaYOg.u.MEQ_2bzQkVVZ5y1J5Q23Se5CU");
|
||||
|
||||
} else if (event.getAuthor().getIdLong() == Config.NILS_ID || event.getAuthor().getIdLong() == Config.YUKI_ID) {
|
||||
if (args.startsWith("help")) {
|
||||
EmbedBuilder builder = Config.getDefaultEmbed()
|
||||
.setTitle("Bot Admin only")
|
||||
.addField("shutdown", "shutdown the bot", false)
|
||||
.addField("triviadump", "Get JSON", false)
|
||||
.addField("triviaset", "Set JSON. Make sure to backup the JSON beforehand with `triviadump`", false)
|
||||
.addField("reloadtrivia", "Reload the new trivia File", false)
|
||||
.addField("jar", "Upload a new jar file", false);
|
||||
reply(builder.build());
|
||||
} else if (args.startsWith("shutdown")) {
|
||||
reply("Shutting down KilluaBot...");
|
||||
System.exit(0);
|
||||
} else if (args.startsWith("triviadump")) {
|
||||
File f = TriviaQuestionData.getFile();
|
||||
event.getTextChannel().sendMessage("Trivia Questions JSON File:").addFile(f).queue();
|
||||
} else if (args.startsWith("triviaset")) {
|
||||
List<Message.Attachment> attachments = event.getMessage().getAttachments();
|
||||
if (attachments.size() > 0) {
|
||||
attachments.get(0).downloadToFile(TriviaQuestionData.getFile());
|
||||
} else {
|
||||
reply("JSON File not found");
|
||||
String[] command = args.split(" ");
|
||||
switch (command[0]) {
|
||||
case "help" -> {
|
||||
EmbedBuilder builder = Config.getDefaultEmbed()
|
||||
.setTitle("Bot Admin only")
|
||||
.addField("shutdown", "shutdown the bot", false)
|
||||
.addField("triviadump", "Get JSON", false)
|
||||
.addField("triviaset", "Set JSON. Make sure to backup the JSON beforehand with `triviadump`", false)
|
||||
.addField("reloadtrivia", "Reload the new trivia File", false)
|
||||
.addField("jar", "Upload a new jar file", false);
|
||||
reply(builder.build());
|
||||
}
|
||||
} else if (args.startsWith("reloadtrivia")) {
|
||||
TriviaQuestionData.reload();
|
||||
reply("Reloaded Trivia Questions");
|
||||
} else if (args.startsWith("jar")) {
|
||||
List<Message.Attachment> attachments = event.getMessage().getAttachments();
|
||||
if (attachments.size() > 0) {
|
||||
try {
|
||||
attachments.get(0).downloadToFile(
|
||||
new File(EvalCommand.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation().toURI()));
|
||||
reply("Downloaded jar file");
|
||||
} catch (URISyntaxException e) {
|
||||
reply("Error: " + e.getMessage());
|
||||
case "shutdown" -> {
|
||||
reply("Shutting down KilluaBot...");
|
||||
System.exit(0);
|
||||
}
|
||||
case "triviadump" -> {
|
||||
File f = TriviaQuestionData.getFile();
|
||||
event.getTextChannel().sendMessage("Trivia Questions JSON File:").addFile(f).queue();
|
||||
}
|
||||
case "triviaset" -> {
|
||||
List<Message.Attachment> attachments = event.getMessage().getAttachments();
|
||||
if (attachments.size() > 0) {
|
||||
attachments.get(0).downloadToFile(TriviaQuestionData.getFile());
|
||||
} else {
|
||||
reply("JSON File not found");
|
||||
}
|
||||
} else {
|
||||
reply("JSON File not found");
|
||||
}
|
||||
case "reloadtrivia" -> {
|
||||
TriviaQuestionData.reload();
|
||||
reply("Reloaded Trivia Questions");
|
||||
}
|
||||
case "jar" -> {
|
||||
List<Message.Attachment> attachments = event.getMessage().getAttachments();
|
||||
if (attachments.size() > 0) {
|
||||
try {
|
||||
attachments.get(0).downloadToFile(
|
||||
new File(EvalCommand.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation().toURI()));
|
||||
reply("Downloaded jar file");
|
||||
} catch (URISyntaxException e) {
|
||||
reply("Error: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
reply("JSON File not found");
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
reply("Command is invalid.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,5 @@ public class InviteCommand extends Command {
|
|||
.addField("Invite link", "[Invite]" + INVITE_LINK, true)
|
||||
.setFooter("This bot was made by " + nils.getAsTag(), nils.getAvatarUrl());
|
||||
reply(builder.build());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue