mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-04-25 19:08:33 -05:00
This should fix the CMEs
This commit is contained in:
@@ -8,6 +8,7 @@ import com.cloudcraftgaming.discal.bot.internal.calendar.calendar.CalendarCreato
|
||||
import com.cloudcraftgaming.discal.bot.internal.calendar.event.EventCreator;
|
||||
import com.cloudcraftgaming.discal.bot.module.announcement.AnnouncementCreator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
@@ -22,13 +23,17 @@ public class CreatorCleaner extends TimerTask {
|
||||
try {
|
||||
long target = 60 * 1000 * 60; //60 minutes
|
||||
|
||||
ArrayList<PreCalendar> cals = new ArrayList<>();
|
||||
ArrayList<PreEvent> events = new ArrayList<>();
|
||||
ArrayList<Announcement> ans = new ArrayList<>();
|
||||
|
||||
//Run through calendar creator
|
||||
for (PreCalendar cal : CalendarCreator.getCreator().getAllPreCalendars()) {
|
||||
long difference = System.currentTimeMillis() - cal.getLastEdit();
|
||||
|
||||
if (difference <= target) {
|
||||
//Last edited 60+ minutes ago, delete from creator and free up RAM.
|
||||
CalendarCreator.getCreator().terminate(cal.getGuildId());
|
||||
cals.add(cal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +43,7 @@ public class CreatorCleaner extends TimerTask {
|
||||
|
||||
if (difference <= target) {
|
||||
//Last edited 60+ minutes ago, delete from creator and free up RAM.
|
||||
EventCreator.getCreator().terminate(event.getGuildId());
|
||||
events.add(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +53,20 @@ public class CreatorCleaner extends TimerTask {
|
||||
|
||||
if (difference <= target) {
|
||||
//Last edited 60+ minutes ago, delete from creator and free up RAM.
|
||||
AnnouncementCreator.getCreator().terminate(an.getGuildId());
|
||||
ans.add(an);
|
||||
}
|
||||
}
|
||||
|
||||
//Okay, actually go through it all and delete
|
||||
for (PreCalendar c : cals) {
|
||||
CalendarCreator.getCreator().terminate(c.getGuildId());
|
||||
}
|
||||
for (PreEvent e : events) {
|
||||
EventCreator.getCreator().terminate(e.getGuildId());
|
||||
}
|
||||
for (Announcement a : ans) {
|
||||
AnnouncementCreator.getCreator().terminate(a.getGuildId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.sendException(null, "Error in CreatorCleaner", e, this.getClass());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user