Browse Source

Updated admin events to read

master
MagicBot 2 years ago
parent
commit
87dfc968aa
  1. 23
      src/discord/Database.java
  2. 12
      src/discord/MagicBot.java

23
src/discord/Database.java

@ -257,6 +257,29 @@ public class Database { @@ -257,6 +257,29 @@ public class Database {
return trashCount;
}
public void setAdminEventAsRead(int adminEvent) {
String queryString = "UPDATE dyn_admin_log SET `SentFlag` = 1 WHERE `entry` = ? ";
try (Connection connection = DriverManager.getConnection(sqlURI, ConfigManager.MB_DATABASE_USER.getValue(),
ConfigManager.MB_DATABASE_PASS.getValue())) {
PreparedStatement updateAdminEvent = connection.prepareCall(queryString);
updateAdminEvent.setInt(1, adminEvent);
updateAdminEvent.executeUpdate();
updateAdminEvent.close();
return;
} catch (SQLException e) {
Logger.error(e.toString());
online = false;
return;
}
}
public HashMap<Integer, String> getAdminEvents() {
HashMap<Integer, String> outMap = new HashMap<>();

12
src/discord/MagicBot.java

@ -380,14 +380,20 @@ public class MagicBot extends ListenerAdapter { @@ -380,14 +380,20 @@ public class MagicBot extends ListenerAdapter {
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (String adminEvent : adminEvents.values()) {
String outString =
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
/* String outString =
"```\n" + "Hello Players \n\n" +
adminEvent + "\n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
*/
Logger.info(adminEvents.get(adminEvent));
}
}
}

Loading…
Cancel
Save