Skip to content

Commit ff9e049

Browse files
committed
Upcoming event static messages should not include ongoing events when updating
1 parent 1904161 commit ff9e049

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

core/src/main/kotlin/org/dreamexposure/discal/core/business/StaticMessageService.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ class StaticMessageService(
107107
val events = calendarService.getEventsInNextNDays(guildId, calendarNumber, 7)
108108
embed = embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true)
109109
}
110+
110111
StaticMessage.Type.NEXT_EVENT -> {
111-
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1).firstOrNull()
112+
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 5).firstOrNull { !it.isOngoing() }
112113
if (event != null) {
113114
additionalComponents.addAll(componentService.getEventRsvpComponents(event, settings))
114115
forcedUpdate = event.end
@@ -117,7 +118,7 @@ class StaticMessageService(
117118
embed = embedService.nextUpcomingEventEmbed(event, null, settings, includeRsvp = false, showUpdate = true)
118119
}
119120
StaticMessage.Type.NEXT_EVENT_WITH_RSVP -> {
120-
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1).firstOrNull()
121+
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 5).firstOrNull { !it.isOngoing() }
121122
val rsvp = if (event == null) null else rsvpService.getRsvp(guildId, event.id)
122123
if (event != null) {
123124
additionalComponents.addAll(componentService.getEventRsvpComponents(event, settings, true))
@@ -221,7 +222,7 @@ class StaticMessageService(
221222
embed = embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true)
222223
}
223224
StaticMessage.Type.NEXT_EVENT -> {
224-
val event = calendarService.getUpcomingEvents(guildId, old.calendarNumber, 1).firstOrNull()
225+
val event = calendarService.getUpcomingEvents(guildId, old.calendarNumber, 5).firstOrNull { !it.isOngoing() }
225226
if (event != null) {
226227
additionalComponents.addAll(componentService.getEventRsvpComponents(event, settings))
227228
forcedUpdate = event.end
@@ -230,7 +231,7 @@ class StaticMessageService(
230231
embed = embedService.nextUpcomingEventEmbed(event, null, settings, includeRsvp = false, showUpdate = true)
231232
}
232233
StaticMessage.Type.NEXT_EVENT_WITH_RSVP -> {
233-
val event = calendarService.getUpcomingEvents(guildId, old.calendarNumber, 1).firstOrNull()
234+
val event = calendarService.getUpcomingEvents(guildId, old.calendarNumber, 5).firstOrNull { !it.isOngoing() }
234235
val rsvp = if (event == null) null else rsvpService.getRsvp(guildId, event.id)
235236
if (event != null) {
236237
additionalComponents.addAll(componentService.getEventRsvpComponents(event, settings, true))
@@ -340,7 +341,7 @@ class StaticMessageService(
340341
embed = embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true)
341342
}
342343
StaticMessage.Type.NEXT_EVENT -> {
343-
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1).firstOrNull()
344+
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 5).firstOrNull { !it.isOngoing() }
344345
if (event != null) {
345346
additionalComponents.addAll(componentService.getEventRsvpComponents(event, settings))
346347
forcedUpdate = event.end
@@ -349,7 +350,7 @@ class StaticMessageService(
349350
embed = embedService.nextUpcomingEventEmbed(event, null, settings, includeRsvp = false, showUpdate = true)
350351
}
351352
StaticMessage.Type.NEXT_EVENT_WITH_RSVP -> {
352-
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1).firstOrNull()
353+
val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 5).firstOrNull { !it.isOngoing() }
353354
val rsvp = if (event == null) null else rsvpService.getRsvp(guildId, event.id)
354355
if (event != null) {
355356
additionalComponents.addAll(componentService.getEventRsvpComponents(event, settings, true))

0 commit comments

Comments
 (0)