mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-04-27 04:40:31 -05:00
Realized I forgot to actually confirm announcement was enabled
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
+2
-1
@@ -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...
|
||||
|
||||
Reference in New Issue
Block a user