mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-14 15:15:01 +01:00
first deplayable version
This commit is contained in:
parent
e3a7db9b56
commit
df24105467
6 changed files with 68 additions and 7 deletions
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>groupId</groupId>
|
||||
<artifactId>KilluaBot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>15</maven.compiler.source>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public class Config {
|
|||
|
||||
public static final long THIS_ID = 801015254023798825L;
|
||||
public static final long NILS_ID = 414755070161453076L;
|
||||
public static final long YUKI_ID = 265849018662387712L;
|
||||
public static final long KUKUROO_MOUNTAIN_ID = 799696420386504795L;
|
||||
public static final long TRIVIA_APPROVAL_CHANNEL_ID = 802244298774413312L;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,17 @@
|
|||
package com.github.nilstrieb.commands.info;
|
||||
|
||||
import com.github.nilstrieb.cofig.Config;
|
||||
import com.github.nilstrieb.commands.handler.Command;
|
||||
import com.github.nilstrieb.util.trivia.TriviaQuestionData;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
public class EvalCommand extends Command {
|
||||
public EvalCommand() {
|
||||
super("eval", true);
|
||||
|
|
@ -10,10 +19,52 @@ public class EvalCommand extends Command {
|
|||
|
||||
@Override
|
||||
public void called(MessageReceivedEvent event, String args) {
|
||||
if(args.startsWith("event.getJDA().getToken()")){
|
||||
reply(event, "ODAxDKE1MjU0UDOzNzk4ODI1.YAaYOg.u.MEQ_2bzQkVVZ5y1J5Q23Se5CU");
|
||||
if (args.startsWith("event.getJDA().getToken()")) {
|
||||
reply(event, "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(event)
|
||||
.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(event, builder.build());
|
||||
} else if (args.startsWith("shutdown")) {
|
||||
reply(event, "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(event, "No arguments provided.");
|
||||
reply(event, "JSON File not found");
|
||||
}
|
||||
} else if (args.startsWith("reloadtrivia")) {
|
||||
TriviaQuestionData.reload();
|
||||
reply(event, "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(event, "Downloaded jar file");
|
||||
} catch (URISyntaxException e) {
|
||||
reply(event, "Error: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
reply(event, "JSON File not found");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reply(event, "no eval for you");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class ToukaCommand extends Command {
|
|||
|
||||
@Override
|
||||
public void called(MessageReceivedEvent event, String args) {
|
||||
event.getJDA().retrieveUserById(265849018662387712L).queue(yuki -> {
|
||||
event.getJDA().retrieveUserById(Config.YUKI_ID).queue(yuki -> {
|
||||
event.getJDA().retrieveUserById(783720725848129566L).queue(touka -> {
|
||||
EmbedBuilder builder = Config.getDefaultEmbed(event)
|
||||
.setTitle("Invite the Touka bot")
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ public class Main {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
line = scanner.nextLine();
|
||||
}
|
||||
System.exit(0);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class TriviaQuestionData {
|
|||
}
|
||||
}
|
||||
private static final String JSON_PATH_INTELLIJ = "trivia_questions.json";
|
||||
private static final String JSON_PATH = JSON_PATH_JAR;
|
||||
private static final String JSON_PATH = JSON_PATH_INTELLIJ;
|
||||
|
||||
static {
|
||||
questions.add(new ArrayList<>());
|
||||
|
|
@ -39,6 +39,10 @@ public class TriviaQuestionData {
|
|||
loadJSON();
|
||||
}
|
||||
|
||||
public static File getFile() {
|
||||
return new File(JSON_PATH);
|
||||
}
|
||||
|
||||
private static void loadJSON() {
|
||||
|
||||
System.out.println("[TriviaQuestionData 44] Load JSON File");
|
||||
|
|
@ -127,6 +131,11 @@ public class TriviaQuestionData {
|
|||
return getTotalQuestions(questions.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
public static void reload() {
|
||||
loadJSON();
|
||||
}
|
||||
|
||||
public static void dump() {
|
||||
int i = 0;
|
||||
for (List<TriviaQuestion> question : questions) {
|
||||
|
|
@ -138,4 +147,5 @@ public class TriviaQuestionData {
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue