mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-14 15:15:01 +01:00
config changes
This commit is contained in:
parent
df24105467
commit
ab90751c21
3 changed files with 29 additions and 19 deletions
|
|
@ -1,13 +1,20 @@
|
|||
package com.github.nilstrieb.cofig;
|
||||
|
||||
import com.github.nilstrieb.util.trivia.TriviaQuestionData;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.Event;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class Config {
|
||||
public static final String PREFIX = "kil ";
|
||||
public static final String D_PREFIX = "kil ";
|
||||
public static final String L_PREFIX = "k ";
|
||||
|
||||
public static final String PREFIX = L_PREFIX;
|
||||
|
||||
public static final Color DEFAULT_COLOR = new Color(229, 201, 255);
|
||||
|
||||
public static final long THIS_ID = 801015254023798825L;
|
||||
|
|
@ -16,6 +23,19 @@ public class Config {
|
|||
public static final long KUKUROO_MOUNTAIN_ID = 799696420386504795L;
|
||||
public static final long TRIVIA_APPROVAL_CHANNEL_ID = 802244298774413312L;
|
||||
|
||||
private static String JSON_PATH_JAR;
|
||||
|
||||
static {
|
||||
try {
|
||||
JSON_PATH_JAR = new File(TriviaQuestionData.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation().toURI()).getPath().replaceAll("(.*\\\\).*?\\.jar", "$1") + "trivia_questions.json";;
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static final String JSON_PATH_INTELLIJ = "trivia_questions.json";
|
||||
public static final String JSON_PATH = JSON_PATH_INTELLIJ;
|
||||
|
||||
public static EmbedBuilder getDefaultEmbed(Event event) {
|
||||
User killua = event.getJDA().getUserById(THIS_ID);
|
||||
if (killua == null) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.Scanner;
|
|||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws LoginException {
|
||||
JDABuilder builder = JDABuilder.createDefault(Secrets.TOKEN);
|
||||
JDABuilder builder = JDABuilder.createDefault(Secrets.L_TOKEN);
|
||||
builder.setCompression(Compression.ZLIB);
|
||||
builder.setActivity(Activity.watching("over Gon"));
|
||||
|
||||
|
|
|
|||
|
|
@ -4,27 +4,17 @@ import com.github.nilstrieb.util.ConsoleColors;
|
|||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.github.nilstrieb.cofig.Config.JSON_PATH;
|
||||
|
||||
public class TriviaQuestionData {
|
||||
static List<List<TriviaQuestion>> questions = new ArrayList<>();
|
||||
private static final Random random = new Random();
|
||||
|
||||
private static String JSON_PATH_JAR;
|
||||
|
||||
static {
|
||||
try {
|
||||
JSON_PATH_JAR = new File(TriviaQuestionData.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation().toURI()).getPath().replaceAll("(.*\\\\).*?\\.jar", "$1") + "trivia_questions.json";;
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static final String JSON_PATH_INTELLIJ = "trivia_questions.json";
|
||||
private static final String JSON_PATH = JSON_PATH_INTELLIJ;
|
||||
|
||||
static {
|
||||
questions.add(new ArrayList<>());
|
||||
|
|
@ -69,11 +59,11 @@ public class TriviaQuestionData {
|
|||
|
||||
}
|
||||
|
||||
private static void saveJSON(String path, TriviaQuestion[] array) {
|
||||
private static void saveJSON(TriviaQuestion[] array) {
|
||||
Gson gson = new Gson();
|
||||
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(
|
||||
new FileWriter(path))) {
|
||||
new FileWriter(JSON_PATH))) {
|
||||
|
||||
String json = gson.toJson(array);
|
||||
bufferedWriter.write(json);
|
||||
|
|
@ -84,7 +74,7 @@ public class TriviaQuestionData {
|
|||
}
|
||||
}
|
||||
|
||||
private static void saveJSONFromAll(String path) {
|
||||
private static void saveJSONFromAll() {
|
||||
TriviaQuestion[] questionsArray = new TriviaQuestion[getTotalQuestions()];
|
||||
|
||||
int i = 0;
|
||||
|
|
@ -95,12 +85,12 @@ public class TriviaQuestionData {
|
|||
}
|
||||
}
|
||||
|
||||
saveJSON(path, questionsArray);
|
||||
saveJSON(questionsArray);
|
||||
}
|
||||
|
||||
public static void add(TriviaQuestion triviaQuestion) {
|
||||
questions.get(triviaQuestion.getArc()).add(triviaQuestion);
|
||||
saveJSONFromAll(JSON_PATH);
|
||||
saveJSONFromAll();
|
||||
}
|
||||
|
||||
public static TriviaQuestion getQuestion(int toArc) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue