@@ -3,6 +3,7 @@ package org.dreamexposure.discal.core.business
33import discord4j.common.util.Snowflake
44import discord4j.core.DiscordClient
55import discord4j.core.`object`.component.LayoutComponent
6+ import discord4j.core.spec.EmbedCreateSpec
67import discord4j.discordjson.json.MessageCreateRequest
78import discord4j.discordjson.json.MessageEditRequest
89import discord4j.rest.http.client.ClientException
@@ -91,17 +92,20 @@ class StaticMessageService(
9192 .truncatedTo(ChronoUnit .DAYS )
9293 .plusHours(updateHour + 24 )
9394 .toInstant()
95+
96+ val embed: EmbedCreateSpec
9497 val additionalComponents = mutableListOf<LayoutComponent >()
9598 var forcedUpdate: Instant ? = null
9699
97- val embed = when (type) {
100+ // Handle type specific behavior and rendering
101+ when (type) {
98102 StaticMessage .Type .CALENDAR_OVERVIEW -> {
99103 val events = calendarService.getUpcomingEvents(guildId, calendarNumber, OVERVIEW_EVENT_COUNT )
100- embedService.calendarOverviewEmbed(calendar, events, showUpdate = true )
104+ embed = embedService.calendarOverviewEmbed(calendar, events, showUpdate = true )
101105 }
102106 StaticMessage .Type .CALENDAR_WEEKLY -> {
103- val events = calendarService.getEventsInNextNDays(guildId, calendarNumber, 6 )
104- embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true )
107+ val events = calendarService.getEventsInNextNDays(guildId, calendarNumber, 7 )
108+ embed = embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true )
105109 }
106110 StaticMessage .Type .NEXT_EVENT -> {
107111 val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1 ).firstOrNull()
@@ -110,7 +114,7 @@ class StaticMessageService(
110114 forcedUpdate = event.end
111115 }
112116
113- embedService.nextUpcomingEventEmbed(event, null , settings, includeRsvp = false , showUpdate = true )
117+ embed = embedService.nextUpcomingEventEmbed(event, null , settings, includeRsvp = false , showUpdate = true )
114118 }
115119 StaticMessage .Type .NEXT_EVENT_WITH_RSVP -> {
116120 val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1 ).firstOrNull()
@@ -120,7 +124,7 @@ class StaticMessageService(
120124 forcedUpdate = event.end
121125 }
122126
123- embedService.nextUpcomingEventEmbed(event, rsvp, settings, includeRsvp = true , showUpdate = true )
127+ embed = embedService.nextUpcomingEventEmbed(event, rsvp, settings, includeRsvp = true , showUpdate = true )
124128 }
125129 }
126130
@@ -204,14 +208,17 @@ class StaticMessageService(
204208 // Finally update the message
205209 var forcedUpdate: Instant ? = null
206210 val additionalComponents = mutableListOf<LayoutComponent >()
207- val embed = when (old.type) {
211+ val embed: EmbedCreateSpec
212+
213+ // Handle type specific behavior and rendering
214+ when (old.type) {
208215 StaticMessage .Type .CALENDAR_OVERVIEW -> {
209216 val events = calendarService.getUpcomingEvents(guildId, old.calendarNumber, OVERVIEW_EVENT_COUNT , MAX_CUTOFF_DAYS )
210- embedService.calendarOverviewEmbed(calendar, events, showUpdate = true )
217+ embed = embedService.calendarOverviewEmbed(calendar, events, showUpdate = true )
211218 }
212219 StaticMessage .Type .CALENDAR_WEEKLY -> {
213- val events = calendarService.getEventsInNextNDays(guildId, old.calendarNumber, 6 )
214- embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true )
220+ val events = calendarService.getEventsInNextNDays(guildId, old.calendarNumber, 7 )
221+ embed = embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true )
215222 }
216223 StaticMessage .Type .NEXT_EVENT -> {
217224 val event = calendarService.getUpcomingEvents(guildId, old.calendarNumber, 1 ).firstOrNull()
@@ -220,7 +227,7 @@ class StaticMessageService(
220227 forcedUpdate = event.end
221228 }
222229
223- embedService.nextUpcomingEventEmbed(event, null , settings, includeRsvp = false , showUpdate = true )
230+ embed = embedService.nextUpcomingEventEmbed(event, null , settings, includeRsvp = false , showUpdate = true )
224231 }
225232 StaticMessage .Type .NEXT_EVENT_WITH_RSVP -> {
226233 val event = calendarService.getUpcomingEvents(guildId, old.calendarNumber, 1 ).firstOrNull()
@@ -230,7 +237,7 @@ class StaticMessageService(
230237 forcedUpdate = event.end
231238 }
232239
233- embedService.nextUpcomingEventEmbed(event, rsvp, settings, includeRsvp = true , showUpdate = true )
240+ embed = embedService.nextUpcomingEventEmbed(event, rsvp, settings, includeRsvp = true , showUpdate = true )
234241 }
235242 }
236243
@@ -320,14 +327,17 @@ class StaticMessageService(
320327
321328 var forcedUpdate: Instant ? = null
322329 val additionalComponents = mutableListOf<LayoutComponent >()
323- val embed = when (old.type) {
330+ val embed: EmbedCreateSpec
331+
332+ // Handle type specific behavior and rendering
333+ when (old.type) {
324334 StaticMessage .Type .CALENDAR_OVERVIEW -> {
325335 val events = calendarService.getUpcomingEvents(guildId, calendarNumber, OVERVIEW_EVENT_COUNT )
326- embedService.calendarOverviewEmbed(calendar, events, showUpdate = true )
336+ embed = embedService.calendarOverviewEmbed(calendar, events, showUpdate = true )
327337 }
328338 StaticMessage .Type .CALENDAR_WEEKLY -> {
329- val events = calendarService.getEventsInNextNDays(guildId, calendarNumber, 6 )
330- embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true )
339+ val events = calendarService.getEventsInNextNDays(guildId, calendarNumber, 7 )
340+ embed = embedService.calendarWeekOverviewEmbed(calendar, events, showUpdate = true )
331341 }
332342 StaticMessage .Type .NEXT_EVENT -> {
333343 val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1 ).firstOrNull()
@@ -336,7 +346,7 @@ class StaticMessageService(
336346 forcedUpdate = event.end
337347 }
338348
339- embedService.nextUpcomingEventEmbed(event, null , settings, includeRsvp = false , showUpdate = true )
349+ embed = embedService.nextUpcomingEventEmbed(event, null , settings, includeRsvp = false , showUpdate = true )
340350 }
341351 StaticMessage .Type .NEXT_EVENT_WITH_RSVP -> {
342352 val event = calendarService.getUpcomingEvents(guildId, calendarNumber, 1 ).firstOrNull()
@@ -346,7 +356,7 @@ class StaticMessageService(
346356 forcedUpdate = event.end
347357 }
348358
349- embedService.nextUpcomingEventEmbed(event, rsvp, settings, includeRsvp = true , showUpdate = true )
359+ embed = embedService.nextUpcomingEventEmbed(event, rsvp, settings, includeRsvp = true , showUpdate = true )
350360 }
351361 }
352362
0 commit comments