mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-15 23:55:02 +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 {
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -21,44 +21,55 @@ 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(" ");
|
||||||
EmbedBuilder builder = Config.getDefaultEmbed()
|
switch (command[0]) {
|
||||||
.setTitle("Bot Admin only")
|
case "help" -> {
|
||||||
.addField("shutdown", "shutdown the bot", false)
|
EmbedBuilder builder = Config.getDefaultEmbed()
|
||||||
.addField("triviadump", "Get JSON", false)
|
.setTitle("Bot Admin only")
|
||||||
.addField("triviaset", "Set JSON. Make sure to backup the JSON beforehand with `triviadump`", false)
|
.addField("shutdown", "shutdown the bot", false)
|
||||||
.addField("reloadtrivia", "Reload the new trivia File", false)
|
.addField("triviadump", "Get JSON", false)
|
||||||
.addField("jar", "Upload a new jar file", false);
|
.addField("triviaset", "Set JSON. Make sure to backup the JSON beforehand with `triviadump`", false)
|
||||||
reply(builder.build());
|
.addField("reloadtrivia", "Reload the new trivia File", false)
|
||||||
} else if (args.startsWith("shutdown")) {
|
.addField("jar", "Upload a new jar file", false);
|
||||||
reply("Shutting down KilluaBot...");
|
reply(builder.build());
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
} else if (args.startsWith("reloadtrivia")) {
|
case "shutdown" -> {
|
||||||
TriviaQuestionData.reload();
|
reply("Shutting down KilluaBot...");
|
||||||
reply("Reloaded Trivia Questions");
|
System.exit(0);
|
||||||
} else if (args.startsWith("jar")) {
|
}
|
||||||
List<Message.Attachment> attachments = event.getMessage().getAttachments();
|
case "triviadump" -> {
|
||||||
if (attachments.size() > 0) {
|
File f = TriviaQuestionData.getFile();
|
||||||
try {
|
event.getTextChannel().sendMessage("Trivia Questions JSON File:").addFile(f).queue();
|
||||||
attachments.get(0).downloadToFile(
|
}
|
||||||
new File(EvalCommand.class.getProtectionDomain().getCodeSource()
|
case "triviaset" -> {
|
||||||
.getLocation().toURI()));
|
List<Message.Attachment> attachments = event.getMessage().getAttachments();
|
||||||
reply("Downloaded jar file");
|
if (attachments.size() > 0) {
|
||||||
} catch (URISyntaxException e) {
|
attachments.get(0).downloadToFile(TriviaQuestionData.getFile());
|
||||||
reply("Error: " + e.getMessage());
|
} 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 {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -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());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue