refactored code

This commit is contained in:
anthorob committed 2021-11-07 10:23:19 -05:00
1 parent 325aa1df77
commit 9902a3c913
4 files changed
+8 -12

No files matched your search

-10
View File
@@ -56,16 +56,6 @@ public class MusicBot {
MusicBot.shutdown(); MusicBot.shutdown();
})); }));
ConsoleHandler consoleInput = new ConsoleHandler();
switch (consoleInput.init()) {
case "quit":
System.exit(0);
break;
}
} }
public static void shutdown() { public static void shutdown() {
@@ -25,9 +25,11 @@ public class MysqlConnector {
* @return {@link MysqlConnector} * @return {@link MysqlConnector}
*/ */
public MysqlConnector connect() throws SQLException { public MysqlConnector connect() throws SQLException {
String jdbc = "jdbc:mysql://" + dbHost + ":3306/" + dbName;
try { try {
Class.forName("com.mysql.cj.jdbc.Driver"); Class.forName("com.mysql.cj.jdbc.Driver");
c = DriverManager.getConnection("jdbc:mysql://" + dbHost + ":3306/" + dbName, dbUser, dbPass); c = DriverManager.getConnection(jdbc, dbUser, dbPass);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -13,6 +13,7 @@ public class DBGuild extends AbstractController {
public void insertGuildInDB(Guild g) { public void insertGuildInDB(Guild g) {
if (!database.exists("guilds", "guild_id", g.getId())) { if (!database.exists("guilds", "guild_id", g.getId())) {
database.prepareAndExecuteAsync("INSERT INTO guilds VALUES(?, ?, ?)", g.getId(), "0", null).blocking(); database.prepareAndExecuteAsync("INSERT INTO guilds VALUES(?, ?, ?)", g.getId(), "0", null).blocking();
database.prepareAndExecuteAsync("INSERT INTO guild_settings VALUES(?)", g.getId()).blocking();
} }
} }
@@ -63,7 +63,10 @@ public class NewCommandListener extends ListenerAdapter {
} }
} }
c.execute(event, args); if (c.canBeExecutedBy(event.getGuild(), event.getMember())) {
c.execute(event, args);
}
} }
} }
} else { } else {