Realized I forgot to actually confirm announcement was enabled

This commit is contained in:
NovaFox161
2017-12-28 17:36:29 -06:00
parent fd15251ec3
commit 43c4a5b2f6
2 changed files with 41 additions and 1 deletions
@@ -902,6 +902,45 @@ public class DatabaseManager {
announcement.setHoursBefore(res.getInt("HOURS_BEFORE"));
announcement.setMinutesBefore(res.getInt("MINUTES_BEFORE"));
announcement.setInfo(res.getString("INFO"));
announcement.setEnabled(res.getBoolean("ENABLED"));
announcements.add(announcement);
}
}
stmt.close();
}
} catch (SQLException e) {
ExceptionHandler.sendException(null, "Failed to get all announcements.", e, this.getClass());
}
return announcements;
}
public ArrayList<Announcement> getEnabledAnnouncements() {
ArrayList<Announcement> announcements = new ArrayList<>();
try {
if (databaseInfo.getMySQL().checkConnection()) {
String announcementTableName = databaseInfo.getPrefix() + "ANNOUNCEMENTS";
PreparedStatement stmt = databaseInfo.getConnection().prepareStatement("SELECT * FROM " + announcementTableName + " WHERE ENABLED = 1");
ResultSet res = stmt.executeQuery();
while (res.next()) {
if (res.getString("ANNOUNCEMENT_ID") != null) {
Announcement announcement = new Announcement(UUID.fromString(res.getString("ANNOUNCEMENT_ID")), Long.valueOf(res.getString("GUILD_ID")));
announcement.setSubscriberRoleIdsFromString(res.getString("SUBSCRIBERS_ROLE"));
announcement.setSubscriberUserIdsFromString(res.getString("SUBSCRIBERS_USER"));
announcement.setAnnouncementChannelId(res.getString("CHANNEL_ID"));
announcement.setAnnouncementType(AnnouncementType.valueOf(res.getString("ANNOUNCEMENT_TYPE")));
announcement.setEventId(res.getString("EVENT_ID"));
announcement.setEventColor(EventColor.fromNameOrHexOrID(res.getString("EVENT_COLOR")));
announcement.setHoursBefore(res.getInt("HOURS_BEFORE"));
announcement.setMinutesBefore(res.getInt("MINUTES_BEFORE"));
announcement.setInfo(res.getString("INFO"));
//The announcement is obviously enabled if we have gotten here lol
announcement.setEnabled(true);
announcements.add(announcement);
}
@@ -46,7 +46,8 @@ public class AnnouncementTask extends TimerTask {
ExceptionHandler.sendException(null, "Failed to get service! 00a0101", e, this.getClass());
}
ArrayList<Announcement> allAnnouncements = DatabaseManager.getManager().getAnnouncements();
//NOTE: This list EXCLUDES disabled announcements!!!!!!!
ArrayList<Announcement> allAnnouncements = DatabaseManager.getManager().getEnabledAnnouncements();
for (Announcement a : allAnnouncements) {
//Check if guild is part of DisCal's guilds. This way we can clear out the database...