Skip to content
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=6.0.30
version=6.0.31
7 changes: 6 additions & 1 deletion src/main/kotlin/dev/slne/surf/discord/faq/Faq.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,10 @@ enum class Faq(
translatable("faq.command.questions.how-to-whitelist.question"),
translatable("faq.command.questions.how-to-whitelist.answer"),
"gifs/wl-gif.gif"
)
),
PING_PONG(
"ping-pong",
translatable("faq.command.questions.ping-pong.question"),
translatable("faq.command.questions.ping-pong.answer")
),
}
82 changes: 51 additions & 31 deletions src/main/kotlin/dev/slne/surf/discord/faq/command/FaqCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package dev.slne.surf.discord.faq.command

import com.github.benmanes.caffeine.cache.Caffeine
import dev.slne.surf.discord.command.*
import dev.slne.surf.discord.dsl.embed
import dev.slne.surf.discord.faq.Faq
import dev.slne.surf.discord.messages.translatable
import dev.slne.surf.discord.permission.DiscordPermission
import dev.slne.surf.discord.permission.hasPermission
import dev.slne.surf.discord.util.Colors
import net.dv8tion.jda.api.components.container.Container
import net.dv8tion.jda.api.components.container.ContainerChildComponent
import net.dv8tion.jda.api.components.mediagallery.MediaGallery
import net.dv8tion.jda.api.components.mediagallery.MediaGalleryItem
import net.dv8tion.jda.api.components.separator.Separator
import net.dv8tion.jda.api.components.textdisplay.TextDisplay
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.utils.FileUpload
import org.springframework.stereotype.Component
Expand Down Expand Up @@ -41,14 +46,21 @@ import kotlin.time.toJavaDuration
CommandChoice("how-to-join", "how-to-join"),
CommandChoice("ask", "ask"),
CommandChoice("missing-information", "missing-information"),
CommandChoice("how-to-whitelist", "how-to-whitelist")
CommandChoice("how-to-whitelist", "how-to-whitelist"),
CommandChoice("ping-pong", "ping-pong")
]
),
CommandOption(
"user",
"Der Benutzer, für den die Frage angezeigt wird",
CommandOptionType.USER,
false
),
CommandOption(
"info",
"Zeigt das FAQ nur dir selbst an",
CommandOptionType.BOOLEAN,
false
)
]
)
Expand All @@ -57,10 +69,30 @@ class FaqCommand : SlashCommand {
.expireAfterWrite(30.seconds.toJavaDuration())
.build<Long, Pair<Faq, Long>>()

private fun faqComponent(faq: Faq, userMention: String? = null): Container {
val components = mutableListOf<ContainerChildComponent>()

if (userMention != null) {
components += TextDisplay.of(userMention)
components += Separator.createDivider(Separator.Spacing.SMALL)
}

components += TextDisplay.of("## ${faq.question}")
components += TextDisplay.of(faq.answer)

faq.attachmentPath?.let(::File)?.let { file ->
components += Separator.createDivider(Separator.Spacing.LARGE)
components += MediaGallery.of(MediaGalleryItem.fromFile(FileUpload.fromData(file)))
}

return Container.of(components).withAccentColor(Colors.INFO)
}

override suspend fun execute(event: SlashCommandInteractionEvent) {
val interaction = event.interaction
val question = interaction.getOption("question")?.asString ?: return
val user = interaction.getOption("user")?.asUser
val info = interaction.getOption("info")?.asBoolean ?: false
val faq = Faq.entries.find { it.id == question }

if (!event.member.hasPermission(DiscordPermission.COMMAND_FAQ)) {
Expand All @@ -76,6 +108,15 @@ class FaqCommand : SlashCommand {
return
}

if (info) {
event.replyComponents(faqComponent(faq))
.useComponentsV2()
.setEphemeral(true)
.queue()

return
}

if (faqCache.asMap()
.any { it.value.first == faq && it.value.second == event.messageChannel.idLong }
) {
Expand All @@ -85,38 +126,17 @@ class FaqCommand : SlashCommand {

faqCache.put(System.currentTimeMillis(), faq to event.messageChannel.idLong)

val file = faq.attachmentPath?.let(::File)

if (user != null) {
event.reply(user.asMention).setEmbeds(embed {
title = faq.question
description = faq.answer
color = Colors.INFO

if (file != null) {
image = "attachment://${file.name}"
}
}).apply {
if (file != null) {
addFiles(FileUpload.fromData(file))
}
}.queue()
event.replyComponents(faqComponent(faq, user.asMention))
.useComponentsV2()
.mention(user)
.queue()

return
}

event.replyEmbeds(embed {
title = faq.question
description = faq.answer
color = Colors.INFO

if (file != null) {
image = "attachment://${file.name}"
}
}).apply {
if (file != null) {
addFiles(FileUpload.fromData(file))
}
}.queue()
event.replyComponents(faqComponent(faq))
.useComponentsV2()
.queue()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dev.slne.surf.discord.ticket.Ticket
import dev.slne.surf.discord.ticket.database.deadline.DeadlineNotifyRepository
import dev.slne.surf.discord.ticket.database.deadline.ReplyDeadline
import dev.slne.surf.discord.ticket.database.deadline.ReplyDeadlineRepository
import dev.slne.surf.discord.ticket.database.ticket.TicketRepository
import dev.slne.surf.discord.util.Colors
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.launch
Expand All @@ -27,6 +28,7 @@ class ReplyDeadlineService(
private val jda: JDA,
private val replyDeadlineRepository: ReplyDeadlineRepository,
private val deadlineNotifyRepository: DeadlineNotifyRepository,
private val ticketRepository: TicketRepository,
) {

suspend fun createDeadline(ticket: Ticket, target: User, setBy: User, deadline: OffsetDateTime) {
Expand Down Expand Up @@ -69,6 +71,9 @@ class ReplyDeadlineService(
val deleted = replyDeadlineRepository.delete(deadline.id)
if (!deleted) return

val ticket = ticketRepository.getTicketById(deadline.ticketId)
if (ticket == null || ticket.isClosed()) return

try {
if (deadlineNotifyRepository.isEnabled(deadline.setById)) {
notifyDeadlineCreator(deadline)
Expand Down
11 changes: 10 additions & 1 deletion src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ Bitte überprüfe noch einmal, ob du uns alle wichtigen Informationen mitgeteilt
• **Server**, auf dem es aufgetreten ist\n\
• **Koordinaten** (z. B. `110 64 60`)\n\
• **Dimension** (z. B. `Overworld`)\n\
• **Eine genaue Beschreibung des Problems**
• **Eine genaue Beschreibung des Problems**\n\
• **Zeitraumangabe** (z. B. `Gestern 12:30 Uhr bis 13:30 Uhr`)
faq.command.questions.how-to-whitelist.question=Wie werde ich gewhitelisted?
faq.command.questions.how-to-whitelist.answer=Um auf dem Survival-Server gewhitelisted zu werden, gehe in <#1124438644523012234> und klicke dort auf **„Whitelist erstellen“**.\n\nAnschließend öffnet sich ein Formular, in das du deinen **Minecraft-Namen** eintragen musst. Achte darauf, dass dein Name korrekt geschrieben ist.\n\nSobald du das Formular absendest, wirst du automatisch gewhitelisted und kannst dem Server beitreten.
faq.command.questions.ping-pong.question=Antwortzeiten & Pings – das solltet ihr wissen!
faq.command.questions.ping-pong.answer=Warum antwortet das Serverteam nicht sofort?\n\
- Das Serverteam arbeitet ehrenamtlich in seiner Freizeit.\n\
- Wir bemühen uns, bei Problemen und Anliegen so schnell wie möglich zu helfen.\n\
- Pings sind nicht notwendig – das Team sieht alle Nachrichten und Tickets.\n\
- Pings beschleunigen nichts, sie können die Bearbeitung sogar verzögern.\n\
- Bitte habt etwas Geduld und wartet auf eine Antwort.\n\n\
Vielen Dank für euer Verständnis und eure Rücksichtnahme.