Skip to content

Commit 316b02c

Browse files
authored
Merge pull request #169 from DreamExposure/develop
4.2.9 RC
2 parents f71f589 + ae259d3 commit 316b02c

File tree

46 files changed

+459
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+459
-239
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ DisCal uses a simple-to-understand permission scheme for handling access to comm
170170
| `/settings role` | Sets the role required to use privileged commands | elevated |
171171
| `/settings announcement-style` | Changes the style announcements will be posted as | elevated |
172172
| `/settings pause-announcements` | Allows pausing and unpausing all announcements for the guild for a period of time | elevated |
173+
| `/settings show-rsvp-dropdown` | Allows showing/hiding of the "RSVP" dropdown on all announcements and event posts | elevated |
173174
| `/settings language` | Changes the language the bot will use in responses | elevated |
174175
| `/settings time-format` | Changes what format to display date/time when needed | elevated |
175176
| `/settings branding` | Toggles between DisCal branding or the guild's name/image where possible | elevated, patron-only |

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ buildscript {
2828
allprojects {
2929
//Project props
3030
group = "org.dreamexposure.discal"
31-
version = "4.2.8"
31+
version = "4.2.9"
3232
description = "DisCal"
3333

3434
//Plugins

cam/src/main/kotlin/org/dreamexposure/discal/cam/business/cronjob/HeartbeatCronJob.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import okhttp3.Response
99
import org.dreamexposure.discal.core.config.Config
1010
import org.dreamexposure.discal.core.extensions.asSeconds
1111
import org.dreamexposure.discal.core.logger.LOGGER
12-
import org.dreamexposure.discal.core.`object`.network.discal.InstanceData
13-
import org.dreamexposure.discal.core.`object`.rest.HeartbeatRequest
14-
import org.dreamexposure.discal.core.`object`.rest.HeartbeatType
12+
import org.dreamexposure.discal.core.`object`.new.model.discal.HeartbeatV3RequestModel
13+
import org.dreamexposure.discal.core.`object`.new.model.discal.InstanceDataV3Model
1514
import org.dreamexposure.discal.core.utils.GlobalVal.DEFAULT
1615
import org.dreamexposure.discal.core.utils.GlobalVal.JSON
1716
import org.springframework.boot.ApplicationArguments
@@ -38,7 +37,7 @@ class HeartbeatCronJob(
3837

3938
private fun heartbeat() = mono {
4039
try {
41-
val requestBody = HeartbeatRequest(HeartbeatType.CAM, instanceData = InstanceData())
40+
val requestBody = HeartbeatV3RequestModel(HeartbeatV3RequestModel.Type.CAM, instance = InstanceDataV3Model())
4241

4342
val request = Request.Builder()
4443
.url("$apiUrl/v3/status/heartbeat")

client/src/main/kotlin/org/dreamexposure/discal/client/business/cronjob/HeartbeatCronJob.kt

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ package org.dreamexposure.discal.client.business.cronjob
22

33
import com.fasterxml.jackson.databind.ObjectMapper
44
import discord4j.core.GatewayDiscordClient
5-
import kotlinx.coroutines.reactor.awaitSingle
6-
import kotlinx.coroutines.reactor.mono
75
import okhttp3.OkHttpClient
86
import okhttp3.Request
97
import okhttp3.RequestBody.Companion.toRequestBody
108
import okhttp3.Response
119
import org.dreamexposure.discal.core.config.Config
1210
import org.dreamexposure.discal.core.extensions.asSeconds
1311
import org.dreamexposure.discal.core.logger.LOGGER
14-
import org.dreamexposure.discal.core.`object`.network.discal.BotInstanceData
15-
import org.dreamexposure.discal.core.`object`.rest.HeartbeatRequest
16-
import org.dreamexposure.discal.core.`object`.rest.HeartbeatType
12+
import org.dreamexposure.discal.core.`object`.new.model.discal.BotInstanceDataV3Model
13+
import org.dreamexposure.discal.core.`object`.new.model.discal.HeartbeatV3RequestModel
1714
import org.dreamexposure.discal.core.utils.GlobalVal
1815
import org.dreamexposure.discal.core.utils.GlobalVal.DEFAULT
1916
import org.springframework.boot.ApplicationArguments
@@ -39,26 +36,22 @@ class HeartbeatCronJob(
3936
.subscribe()
4037
}
4138

42-
private fun heartbeat() = mono {
43-
try {
44-
val data = BotInstanceData.load(discordClient).awaitSingle()
39+
private fun heartbeat(): Mono<Void> {
40+
return discordClient.guilds.count().map(Long::toInt).map { guildCount ->
41+
val requestBody = HeartbeatV3RequestModel(HeartbeatV3RequestModel.Type.BOT, bot = BotInstanceDataV3Model(guilds = guildCount))
4542

46-
val requestBody = HeartbeatRequest(HeartbeatType.BOT, botInstanceData = data)
47-
val request = Request.Builder()
43+
Request.Builder()
4844
.url("$apiUrl/v3/status/heartbeat")
4945
.post(objectMapper.writeValueAsString(requestBody).toRequestBody(GlobalVal.JSON))
5046
.header("Authorization", "Int ${Config.SECRET_DISCAL_API_KEY.getString()}")
5147
.header("Content-Type", "application/json")
5248
.build()
53-
54-
Mono.fromCallable(httpClient.newCall(request)::execute)
55-
.map(Response::close)
56-
.subscribeOn(Schedulers.boundedElastic())
57-
.doOnError { LOGGER.error(DEFAULT, "[Heartbeat] Failed to heartbeat", it) }
58-
.onErrorResume { Mono.empty() }
59-
.subscribe()
60-
} catch (ex: Exception) {
61-
LOGGER.error(DEFAULT, "[Heartbeat] Failed to heartbeat", ex)
6249
}
50+
.flatMap { Mono.fromCallable(httpClient.newCall(it)::execute) }
51+
.map(Response::close)
52+
.then()
53+
.subscribeOn(Schedulers.boundedElastic())
54+
.doOnError { LOGGER.error(DEFAULT, "[Heartbeat] Failed to heartbeat", it) }
55+
.onErrorResume { Mono.empty() }
6356
}
6457
}

client/src/main/kotlin/org/dreamexposure/discal/client/commands/global/CalendarCommand.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class CalendarCommand(
329329
)
330330
)
331331
calendarService.cancelCalendarWizard(settings.guildId, calendar.metadata.number)
332+
calendarService.cancelCalendarWizard(existingWizard.guildId, event.interaction.user.id)
332333

333334
val message = if (existingWizard.editing) getMessage("confirm.success.edit", settings)
334335
else getMessage("confirm.success.create", settings)

client/src/main/kotlin/org/dreamexposure/discal/client/commands/global/EventCommand.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ class EventCommand(
621621
getMessage("confirm.success.edit", settings)
622622
else getMessage("confirm.success.create", settings)
623623

624+
calendarService.cancelEventWizard(existingWizard.guildId, event.interaction.user.id)
625+
624626
// Basically, since the first followup is just editing the original, what if I delete the original defer message and then create a non-ephemeral followup???
625627
event.interactionResponse.deleteInitialResponse().awaitSingleOrNull()
626628

client/src/main/kotlin/org/dreamexposure/discal/client/commands/global/RsvpCommand.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ class RsvpCommand(
7575

7676
event.createFollowup(getMessage("onTime.success", settings))
7777
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
78-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
78+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
7979
.withEphemeral(ephemeral)
8080
.awaitSingle()
8181
} else {
8282
rsvp = rsvpService.upsertRsvp(rsvp.copyWithUserStatus(userId, waitlist = rsvp.waitlist + userId))
8383

8484
event.createFollowup(getMessage("onTime.failure.limit", settings))
8585
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
86-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
86+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
8787
.withEphemeral(ephemeral)
8888
.awaitSingle()
8989
}
@@ -125,15 +125,15 @@ class RsvpCommand(
125125

126126
event.createFollowup(getMessage("late.success", settings))
127127
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
128-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
128+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
129129
.withEphemeral(ephemeral)
130130
.awaitSingle()
131131
} else {
132132
rsvp = rsvpService.upsertRsvp(rsvp.copy(waitlist = rsvp.waitlist + userId))
133133

134134
event.createFollowup(getMessage("late.failure.limit", settings))
135135
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
136-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
136+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
137137
.withEphemeral(ephemeral)
138138
.awaitSingle()
139139
}
@@ -174,7 +174,7 @@ class RsvpCommand(
174174

175175
return event.createFollowup(getMessage("unsure.success", settings))
176176
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
177-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
177+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
178178
.withEphemeral(ephemeral)
179179
.awaitSingle()
180180
}
@@ -214,7 +214,7 @@ class RsvpCommand(
214214

215215
return event.createFollowup(getMessage("notGoing.success", settings))
216216
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
217-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
217+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
218218
.withEphemeral(ephemeral)
219219
.awaitSingle()
220220
}
@@ -254,7 +254,7 @@ class RsvpCommand(
254254

255255
return event.createFollowup(getMessage("remove.success", settings))
256256
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
257-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
257+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
258258
.withEphemeral(ephemeral)
259259
.awaitSingle()
260260
}
@@ -287,7 +287,7 @@ class RsvpCommand(
287287

288288
return event.createFollowup()
289289
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
290-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
290+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
291291
.withEphemeral(ephemeral)
292292
.awaitSingle()
293293
}
@@ -341,7 +341,7 @@ class RsvpCommand(
341341

342342
return event.createFollowup(getMessage("limit.success", settings, limit.toString()))
343343
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
344-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
344+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
345345
.withEphemeral(ephemeral)
346346
.awaitSingle()
347347
}
@@ -399,7 +399,7 @@ class RsvpCommand(
399399

400400
return event.createFollowup(message)
401401
.withEmbeds(embed)
402-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
402+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
403403
.withEphemeral(ephemeral)
404404
.awaitSingle()
405405
}

client/src/main/kotlin/org/dreamexposure/discal/client/commands/global/SettingsCommand.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class SettingsCommand(
4343
"language" -> language(event, settings)
4444
"time-format" -> timeFormat(event, settings)
4545
"keep-event-duration" -> eventKeepDuration(event, settings)
46+
"show-rsvp-dropdown" -> showRsvpDropdown(event, settings)
4647
"branding" -> branding(event, settings)
4748
"pause-announcements" -> pauseAnnouncements(event, settings)
4849
else -> throw IllegalStateException("Invalid subcommand specified")
@@ -131,6 +132,20 @@ class SettingsCommand(
131132
.awaitSingle()
132133
}
133134

135+
private suspend fun showRsvpDropdown(event: ChatInputInteractionEvent, settings: GuildSettings): Message {
136+
val shown = event.options[0].getOption("shown")
137+
.flatMap(ApplicationCommandInteractionOption::getValue)
138+
.map(ApplicationCommandInteractionOptionValue::asBoolean)
139+
.get()
140+
141+
val newSettings = settingsService.upsertSettings(settings.copy(showRsvpDropdown = shown))
142+
143+
return event.createFollowup(getMessage("showRsvpDropdown.success.$shown", settings))
144+
.withEmbeds(embedService.settingsEmbeds(newSettings))
145+
.withEphemeral(ephemeral)
146+
.awaitSingle()
147+
}
148+
134149
private suspend fun branding(event: ChatInputInteractionEvent, settings: GuildSettings): Message {
135150
val useBranding = event.options[0].getOption("use")
136151
.flatMap(ApplicationCommandInteractionOption::getValue)

client/src/main/kotlin/org/dreamexposure/discal/client/interaction/RsvpDropdown.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class RsvpDropdown(
8787

8888
event.createFollowup(message)
8989
.withEmbeds(embedService.rsvpListEmbed(calendarEvent, rsvp, settings))
90-
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings))
90+
.withComponents(*componentService.getEventRsvpComponents(calendarEvent, settings, alwaysShow = true))
9191
.withEphemeral(ephemeral)
9292
.awaitSingle()
9393
}

client/src/main/kotlin/org/dreamexposure/discal/client/interaction/WizardConfirmButton.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class WizardConfirmButton(
7373
)
7474
)
7575
calendarService.cancelCalendarWizard(settings.guildId, calendar.metadata.number)
76+
calendarService.cancelCalendarWizard(settings.guildId, event.interaction.user.id)
7677

7778
val message = if (existingWizard.editing) getCmdMessage("calendar", "confirm.success.edit", settings.locale)
7879
else getCmdMessage("calendar", "confirm.success.create", settings.locale)
@@ -177,6 +178,8 @@ class WizardConfirmButton(
177178
getCmdMessage("event", "confirm.success.edit", settings.locale)
178179
else getCmdMessage("event", "confirm.success.create", settings.locale)
179180

181+
calendarService.cancelEventWizard(existingWizard.guildId, event.interaction.user.id)
182+
180183
// Basically, since the first followup is just editing the original, what if I delete the original defer message and then create a non-ephemeral followup???
181184
event.interactionResponse.deleteInitialResponse().awaitSingleOrNull()
182185

0 commit comments

Comments
 (0)