Hello my friends

This commit is contained in:
GregTCLTK 2019-11-10 13:16:03 +01:00
parent 8d0aabb09c
commit 352a772fe5
No known key found for this signature in database
GPG key ID: 6C090B9A5D4B3734
4 changed files with 7 additions and 10 deletions

View file

@ -23,7 +23,7 @@ public class Hadder {
startBot(); startBot();
} }
public static void startBot() { private static void startBot() {
Config config = new Config("./config.json"); Config config = new Config("./config.json");
if (!config.fileExists()) config.create(); if (!config.fileExists()) config.create();
config.load(); config.load();

View file

@ -18,11 +18,11 @@ public class Rethink {
private Connection conn; private Connection conn;
private Config config; private Config config;
public Rethink(Config config) { Rethink(Config config) {
this.config = config; this.config = config;
} }
public boolean connect() { public void connect() {
try { try {
conn = r.connection() conn = r.connection()
.hostname(config.getDatabaseIP()) .hostname(config.getDatabaseIP())
@ -35,7 +35,6 @@ public class Rethink {
System.out.println(e.toString()); System.out.println(e.toString());
System.out.println("DB CONNECTION FAILED"); System.out.println("DB CONNECTION FAILED");
} }
return true;
} }
public void disconnect() { public void disconnect() {
@ -46,8 +45,7 @@ public class Rethink {
private JSONArray getAsArray(String table, String where, String value) { private JSONArray getAsArray(String table, String where, String value) {
try { try {
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn); String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);
JSONArray jsonArray = new JSONArray(string); return new JSONArray(string);
return jsonArray;
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
return null; return null;
} catch (Exception e) { } catch (Exception e) {

View file

@ -9,8 +9,8 @@ import java.util.List;
public class CommandHandler { public class CommandHandler {
List<Command> commandList; private List<Command> commandList;
Config config; private Config config;
public CommandHandler(List<Command> commandList, Config config) { public CommandHandler(List<Command> commandList, Config config) {
this.commandList = commandList; this.commandList = commandList;
@ -18,7 +18,6 @@ public class CommandHandler {
} }
public void handle(MessageReceivedEvent event, Rethink rethink, String prefix) { public void handle(MessageReceivedEvent event, Rethink rethink, String prefix) {
StringBuilder regexBuilder = new StringBuilder().append("\\").append(prefix);
String invoke = event.getMessage().getContentRaw().replaceFirst(prefix, "").split(" ")[0]; String invoke = event.getMessage().getContentRaw().replaceFirst(prefix, "").split(" ")[0];
for (Command cmd : commandList) { for (Command cmd : commandList) {
for (String label : cmd.labels()) { for (String label : cmd.labels()) {

View file

@ -33,7 +33,7 @@ public class Config {
public void create() { public void create() {
try { try {
if (Files.notExists(file)) { if (Files.notExists(file)) {
file = Files.createFile(file); Files.createFile(file);
} }
Files.write(file, defaultConfigContent().getBytes()); Files.write(file, defaultConfigContent().getBytes());
} catch (IOException e) { } catch (IOException e) {