Hax dev #10

Merged
greg6775 merged 2 commits from hax-dev into greg-dev 2019-10-27 16:26:34 +01:00
2 changed files with 21 additions and 0 deletions
Showing only changes of commit 441c31a164 - Show all commits

View file

@ -1,6 +1,7 @@
package com.bbn.hadder;
import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlOpFailedError;
import com.rethinkdb.net.Connection;
import com.rethinkdb.net.Cursor;
import com.google.gson.JsonParser;
@ -70,4 +71,23 @@ public class Rethink {
} catch (ClassCastException ignored) {}
return out;
}
public static void setup() {
try {
r.dbCreate("Hadder").run(conn);
} catch (ReqlOpFailedError e) {
System.out.println(e.getMessage());
}
try {
r.tableCreate("server").run(conn);
} catch (ReqlOpFailedError e) {
System.out.println(e.getMessage());
}
try {
r.tableCreate("user").run(conn);
} catch (ReqlOpFailedError e) {
System.out.println(e.getMessage());
}
}
}

View file

@ -11,6 +11,7 @@ public class ReadyListener extends ListenerAdapter {
@Override
public void onReady(@Nonnull ReadyEvent event) {
Rethink.setup();
for (Guild g : event.getJDA().getGuilds()) {
Rethink.insertServer(g.getId());
}