Commented/Removed old db ops that run every time.

This commit is contained in:
Aleksei 2020-02-22 12:15:21 -05:00
parent 7bd40d4b8e
commit a309acd344
2 changed files with 71 additions and 72 deletions

View File

@ -34,7 +34,6 @@ public class Main {
new DiscordApiBuilder().setToken(BotConfig.TOKEN).login().thenAccept(api -> { new DiscordApiBuilder().setToken(BotConfig.TOKEN).login().thenAccept(api -> {
DatabaseUtilities db = new DatabaseUtilities(r, conn, api); DatabaseUtilities db = new DatabaseUtilities(r, conn, api);
db.tableSetup();
Guthix guthix = new Guthix(api, db); Guthix guthix = new Guthix(api, db);

View File

@ -29,7 +29,7 @@ public class DatabaseUtilities {
} }
private Table getTable(String table) { private Table getTable(String table) {
if (this.r.db("fsbot").tableList().contains(table).run(this.conn)) { if (this.r.db("fsbot").tableList().contains(table).run(this.conn) != null) {
return this.r.db("fsbot").table(table); return this.r.db("fsbot").table(table);
} }
else { else {
@ -164,83 +164,83 @@ public class DatabaseUtilities {
.run(conn); .run(conn);
} }
public void newServerProcess(Server server) { // public void newServerProcess(Server server) {
if (this.r.db("fsbot").table("serverConf").contains(server.getIdAsString()).run(this.conn)) { // if (this.r.db("fsbot").table("serverConf").contains(server.getIdAsString()).run(this.conn)) {
return; // return;
} // }
String serverName = server.getName(); // String serverName = server.getName();
String serverId = server.getIdAsString(); // String serverId = server.getIdAsString();
String logChannel = "null"; // String logChannel = "null";
String giveawayChannel = "null"; // String giveawayChannel = "null";
String welcomeChannel = "null"; // String welcomeChannel = "null";
String defaultWelcome = "welcome to the server"; // String defaultWelcome = "welcome to the server";
this.r.db("fsbot").table("serverConf").insert( // this.r.db("fsbot").table("serverConf").insert(
this.r.hashMap("id", serverId) // this.r.hashMap("id", serverId)
.with("name", serverName) // .with("name", serverName)
.with("logChannel", logChannel) // .with("logChannel", logChannel)
.with("giveawayChannel", giveawayChannel) // .with("giveawayChannel", giveawayChannel)
.with("welcomeMsg", defaultWelcome) // .with("welcomeMsg", defaultWelcome)
.with("welcomeChannel", welcomeChannel) // .with("welcomeChannel", welcomeChannel)
.with("prefix", "~") // .with("prefix", "~")
).run(this.conn); // ).run(this.conn);
} // }
public void tableSetup() { // TODO: Fix this -- invert conditionals, just create the tables. -> if *not* exist then create // public void tableSetup() { // TODO: Fix this -- invert conditionals, just create the tables. -> if *not* exist then create
// Check for database existence, if not, create // // Check for database existence, if not, create
if (r.dbList().contains("fsbot").run(conn)) { // if (r.dbList().contains("fsbot").run(conn)) {
// System.out.println("database 'fsbot' already exists."); // // System.out.println("database 'fsbot' already exists.");
} // }
else { // else {
r.dbCreate("fsbot").run(conn); // r.dbCreate("fsbot").run(conn);
System.out.println("database fsbot did not exist, and has been created"); // System.out.println("database fsbot did not exist, and has been created");
} // }
// Check for channels table existence, if not, create // // Check for channels table existence, if not, create
if (r.db("fsbot").tableList().contains("channels").run(conn)) { // if (r.db("fsbot").tableList().contains("channels").run(conn)) {
// System.out.println("table channels already exists"); // // System.out.println("table channels already exists");
} // }
else { // else {
r.db("fsbot").tableCreate("channels").run(conn); // r.db("fsbot").tableCreate("channels").run(conn);
System.out.println("table channels did not exist, and has been created."); // System.out.println("table channels did not exist, and has been created.");
} // }
// Check for serverconf table existence, if not, create // // Check for serverconf table existence, if not, create
if (r.db("fsbot").tableList().contains("serverConf").run(conn)) { // if (r.db("fsbot").tableList().contains("serverConf").run(conn)) {
// System.out.println("table serverConf already exists"); // // System.out.println("table serverConf already exists");
} // }
else { // else {
r.db("fsbot").tableCreate("serverConf").run(conn); // r.db("fsbot").tableCreate("serverConf").run(conn);
System.out.println("table serverConf did not exist, and has been created"); // System.out.println("table serverConf did not exist, and has been created");
} // }
// Check for permissions table existene, if not, create // // Check for permissions table existene, if not, create
if (r.db("fsbot").tableList().contains("permissions").run(conn)) { // if (r.db("fsbot").tableList().contains("permissions").run(conn)) {
// System.out.println("table permissions already exists"); // // System.out.println("table permissions already exists");
} // }
else { // else {
r.db("fsbot").tableCreate("permissions").run(conn); // r.db("fsbot").tableCreate("permissions").run(conn);
System.out.println("table permissions did not exist and has been created"); // System.out.println("table permissions did not exist and has been created");
} // }
// Check for outfits table existence, if not, create // // Check for outfits table existence, if not, create
if (r.db("fsbot").tableList().contains("outfits").run(conn)) { // if (r.db("fsbot").tableList().contains("outfits").run(conn)) {
// System.out.println("table outfits already exists"); // // System.out.println("table outfits already exists");
} // }
else { // else {
r.db("fsbot").tableCreate("outfits").run(conn); // r.db("fsbot").tableCreate("outfits").run(conn);
System.out.println("table outfits did not exist and has been created"); // System.out.println("table outfits did not exist and has been created");
} // }
// Check for colourRoles table existence, if not, create // // Check for colourRoles table existence, if not, create
if (r.db("fsbot").tableList().contains("colourRoles").run(conn)) { // if (r.db("fsbot").tableList().contains("colourRoles").run(conn)) {
// System.out.println("table colourRoles already exists"); // // System.out.println("table colourRoles already exists");
} // }
else { // else {
r.db("fsbot").tableCreate("colourRoles").run(conn); // r.db("fsbot").tableCreate("colourRoles").run(conn);
System.out.println("table colourRoles did not exist and has been created"); // System.out.println("table colourRoles did not exist and has been created");
} // }
} // }
} }