Merge pull request 'Fix Discord Ticket Log' (#43) from VelocityCore/jda-fix into main
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #43 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
dbe6d40e36
@ -46,6 +46,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -86,7 +87,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
||||
MessageChannel messageChannel = event.getChannel();
|
||||
if(messageChannel instanceof TextChannel channel && channel.getParentCategoryIdLong() != 0 && channel.getParentCategoryId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) {
|
||||
LinkedList<StringBuilder> messages = channel.getIterableHistory().complete().stream()
|
||||
LinkedList<StringBuilder> messages = channel.getIterableHistory().reverse().complete().stream()
|
||||
.filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot())
|
||||
.map(message -> {
|
||||
StringBuilder stringBuilder = new StringBuilder()
|
||||
@ -104,7 +105,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
})
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
|
||||
messages.addFirst(new StringBuilder().append("<t:").append(Instant.now().getEpochSecond()).append("> **").append(event.getUser().getName()).append("**: Ticket closed"));
|
||||
messages.add(new StringBuilder().append("<t:").append(Instant.now().getEpochSecond()).append("> **").append(event.getUser().getName()).append("**: Ticket closed"));
|
||||
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder()
|
||||
.setColor(Color.GREEN)
|
||||
@ -118,7 +119,8 @@ public class DiscordTicketHandler extends ListenerAdapter {
|
||||
|
||||
TextChannel logChannel = event.getGuild().getTextChannelById(TICKET_LOG);
|
||||
SplitUtil.split(
|
||||
messages.stream().map(StringBuilder::toString).collect(Collectors.joining("\n")),
|
||||
messages.stream()
|
||||
.map(StringBuilder::toString).collect(Collectors.joining()),
|
||||
2000,
|
||||
SplitUtil.Strategy.NEWLINE,
|
||||
SplitUtil.Strategy.ANYWHERE
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren