From bca45e859c93ee988e307144e522feab79972285 Mon Sep 17 00:00:00 2001 From: Presti Date: Tue, 5 Nov 2024 10:16:26 +0100 Subject: [PATCH] Fix transcript and join message. --- .../de/presti/ree6/events/MenuEvents.java | 4 ++-- .../de/presti/ree6/events/OtherEvents.java | 2 +- .../ree6/utils/data/TranscriptUtil.java | 23 +++++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/presti/ree6/events/MenuEvents.java b/src/main/java/de/presti/ree6/events/MenuEvents.java index c42dc2f2a..ac22fa3ef 100644 --- a/src/main/java/de/presti/ree6/events/MenuEvents.java +++ b/src/main/java/de/presti/ree6/events/MenuEvents.java @@ -173,8 +173,8 @@ public void onButtonInteraction(@NotNull ButtonInteractionEvent event) { webhookMessageBuilder.addEmbeds(webhookEmbedBuilder.build()); webhookMessageBuilder.addFile(event.getGuild().getId() + "_" + ticketEntity.getTicketCount() + "_transcript.html", TranscriptUtil.generateTranscript(event.getJDA(), event.getChannel().asTextChannel().getIterableHistory().reverse().stream().toList(), - event.getChannel().getTimeCreated().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG)).replace("T", " "), - ZonedDateTime.now().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG)).replace("T", " ")).getBytes(StandardCharsets.UTF_8)); + event.getChannel().getTimeCreated().toZonedDateTime().toString().trim(), + ZonedDateTime.now().toOffsetDateTime().toZonedDateTime().toString().trim()).getBytes(StandardCharsets.UTF_8)); WebhookUtil.sendWebhook(null, webhookMessageBuilder.build(), ticketEntity.getLogChannelWebhookId(), ticketEntity.getLogChannelWebhookToken(), WebhookUtil.WebhookTyp.TICKET); diff --git a/src/main/java/de/presti/ree6/events/OtherEvents.java b/src/main/java/de/presti/ree6/events/OtherEvents.java index a4fd4cd0c..988864c8c 100644 --- a/src/main/java/de/presti/ree6/events/OtherEvents.java +++ b/src/main/java/de/presti/ree6/events/OtherEvents.java @@ -155,7 +155,7 @@ public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) { wmb.addFile("welcome.png", ImageCreationUtility.createJoinImage(event.getUser(), joinImage.get().getStringValue(), messageContent.replace("%user_mention%", event.getMember().getUser().getName()))); } catch (IOException e) { - wmb.setContent(messageContent); + wmb.setContent(messageContent.replace("%user_mention%", event.getMember().getUser().getAsMention())); log.error("Error while creating join image!", e); } } else { diff --git a/src/main/java/de/presti/ree6/utils/data/TranscriptUtil.java b/src/main/java/de/presti/ree6/utils/data/TranscriptUtil.java index 94bcd63ca..168801920 100644 --- a/src/main/java/de/presti/ree6/utils/data/TranscriptUtil.java +++ b/src/main/java/de/presti/ree6/utils/data/TranscriptUtil.java @@ -38,16 +38,28 @@ private TranscriptUtil() {
-
Opened: %opened%
-
Transcript Generated: %closed%
+
Opened:
+
Transcript Generated:
Total Messages: %messages_count%
- %messages% +%messages%
+ """; @@ -56,7 +68,7 @@ private TranscriptUtil() { */ public static final String messageTemplate = """
-
%name%%time%
+
%name%
%message%
@@ -77,7 +89,8 @@ public static String generateTranscript(JDA selfUser, List messages, St messageBuilder.append(messageTemplate .replace("%name%", message.getAuthor().getName()) .replace("%time%", message.getTimeCreated().toString()) - .replace("%message%", message.getContentRaw())); + .replace("%message%", message.getContentRaw())) + .append("\n"); } return template