Add debug
This commit is contained in:
1 parent
390e2c3163
commit
4ca4fa7dba
2 files changed
+6
-5
No files matched your search
@@ -135,9 +135,10 @@ public class MysqlDatabase {
|
|||||||
*
|
*
|
||||||
* @param sql The SQL query to execute
|
* @param sql The SQL query to execute
|
||||||
* @param params The parameters to include in the query
|
* @param params The parameters to include in the query
|
||||||
* @return a ResultSet object, which can be converted to a model using {@link MysqlDatabase#convertToTableModel(ResultSet)}
|
* @return a ResultSet object, which can be converted to a model using {@link MysqlDatabase#convertToTableModel(ResultSet, String)}
|
||||||
*/
|
*/
|
||||||
protected synchronized ResultSet prepareAndExecute(String sql, Object... params) {
|
protected synchronized ResultSet prepareAndExecute(String sql, Object... params) {
|
||||||
|
logger.debug(sql);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement query = connection.prepareStatement(sql);
|
PreparedStatement query = connection.prepareStatement(sql);
|
||||||
@@ -157,7 +158,7 @@ public class MysqlDatabase {
|
|||||||
*
|
*
|
||||||
* @param sql The SQL query to execute
|
* @param sql The SQL query to execute
|
||||||
* @param params The parameters to include in the query
|
* @param params The parameters to include in the query
|
||||||
* @return a ResultSet object, which can be converted to a model using {@link MysqlDatabase#convertToTableModel(ResultSet)}
|
* @return a ResultSet object, which can be converted to a model using {@link MysqlDatabase#convertToTableModel(ResultSet, String)}
|
||||||
*/
|
*/
|
||||||
public AsyncMySqlAction prepareAndExecuteAsync(String sql, Object... params) {
|
public AsyncMySqlAction prepareAndExecuteAsync(String sql, Object... params) {
|
||||||
return new AsyncMySqlAction(this, sql, params);
|
return new AsyncMySqlAction(this, sql, params);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.function.Consumer;
|
|||||||
public class DBLogging extends AbstractController {
|
public class DBLogging extends AbstractController {
|
||||||
|
|
||||||
public void getLoggingChannel(String serverId, Consumer<TextChannel> success) {
|
public void getLoggingChannel(String serverId, Consumer<TextChannel> success) {
|
||||||
database.prepareAndExecuteAsync("SELECT channelId FROM logging WHERE serverId = ?", serverId).async((table) -> {
|
database.prepareAndExecuteAsync("SELECT channelId FROM logging WHERE guild_id = ?", serverId).async((table) -> {
|
||||||
TextChannel txt = MusicBot.getJDA().getGuildById(serverId).getTextChannelById((String) table.getRow(0).get(0));
|
TextChannel txt = MusicBot.getJDA().getGuildById(serverId).getTextChannelById((String) table.getRow(0).get(0));
|
||||||
|
|
||||||
success.accept(txt);
|
success.accept(txt);
|
||||||
@@ -36,11 +36,11 @@ public class DBLogging extends AbstractController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void toggleLog(String serverId, String channelId) {
|
public void toggleLog(String serverId, String channelId) {
|
||||||
database.prepareAndExecuteAsync("UPDATE logging SET enabled = NOT enabled WHERE serverId = ? AND channelId = ?", serverId, channelId).blocking();
|
database.prepareAndExecuteAsync("UPDATE logging SET enabled = NOT enabled WHERE guild_id = ? AND channelId = ?", serverId, channelId).blocking();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoggingEnabled(String serverId, String channelId) {
|
public boolean isLoggingEnabled(String serverId, String channelId) {
|
||||||
MTableModel table = database.prepareAndExecuteAsync("SELECT enabled FROM logging WHERE serverId = ? AND channelId = ?", serverId, channelId).blocking();
|
MTableModel table = database.prepareAndExecuteAsync("SELECT enabled FROM logging WHERE guild_id = ? AND channelId = ?", serverId, channelId).blocking();
|
||||||
|
|
||||||
return Boolean.parseBoolean((String) table.getRow(0).get(0));
|
return Boolean.parseBoolean((String) table.getRow(0).get(0));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user