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 {
return trashCount; 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() { public HashMap<Integer, String> getAdminEvents() {
HashMap<Integer, String> outMap = new HashMap<>(); HashMap<Integer, String> outMap = new HashMap<>();

12
src/discord/MagicBot.java

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

Loading…
Cancel
Save