From 87dfc968aa69b5bb75e792eb33092ab1fe869598 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 16 Jan 2023 06:24:24 -0500 Subject: [PATCH] Updated admin events to read --- src/discord/Database.java | 23 +++++++++++++++++++++++ src/discord/MagicBot.java | 12 +++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/discord/Database.java b/src/discord/Database.java index e3fffdd5..c5ef40f2 100644 --- a/src/discord/Database.java +++ b/src/discord/Database.java @@ -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 getAdminEvents() { HashMap outMap = new HashMap<>(); diff --git a/src/discord/MagicBot.java b/src/discord/MagicBot.java index 6002fa20..9175be1e 100644 --- a/src/discord/MagicBot.java +++ b/src/discord/MagicBot.java @@ -380,14 +380,20 @@ public class MagicBot extends ListenerAdapter { private static void SendAdminLogUpdates() { HashMap 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)); } } }