Refactor Discord message sending to use MessageForEmbed object and add support for creating threads in targeted channels.

This commit is contained in:
2025-11-21 23:39:35 +01:00
parent ec3435dccc
commit 0f11167953
4 changed files with 111 additions and 51 deletions
@@ -9,6 +9,7 @@ import com.alttd.altitudeweb.database.litebans.HistoryType;
import com.alttd.altitudeweb.database.litebans.UserType;
import com.alttd.altitudeweb.database.web_db.forms.Appeal;
import com.alttd.altitudeweb.setup.Connection;
import com.alttd.webinterface.objects.MessageForEmbed;
import com.alttd.webinterface.send_message.DiscordSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -97,15 +98,9 @@ public class AppealDiscord {
// colorRgb = null (use default), timestamp = appeal.createdAt if available
Instant timestamp = appeal.createdAt() != null ? appeal.createdAt() : Instant.now();
DiscordSender.getInstance().sendEmbedToChannels(
channelIds,
"New Appeal Submitted",
description,
fields,
null,
timestamp,
null
);
MessageForEmbed newAppealSubmitted = new MessageForEmbed(
"New Appeal Submitted", description, fields, null, timestamp, null);
DiscordSender.getInstance().sendEmbedWithThreadToChannels(channelIds, newAppealSubmitted, "Appeal");
}
private CompletableFuture<Integer> getCountAsync(HistoryType type, java.util.UUID uuid) {
@@ -5,6 +5,7 @@ import com.alttd.altitudeweb.database.discord.OutputChannel;
import com.alttd.altitudeweb.database.discord.OutputChannelMapper;
import com.alttd.altitudeweb.database.web_db.forms.StaffApplication;
import com.alttd.altitudeweb.setup.Connection;
import com.alttd.webinterface.objects.MessageForEmbed;
import com.alttd.webinterface.send_message.DiscordSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -79,16 +80,15 @@ public class StaffApplicationDiscord {
.toList();
Instant timestamp = application.createdAt() != null ? application.createdAt() : Instant.now();
DiscordSender.getInstance().sendEmbedToChannels(
channelIds,
MessageForEmbed messageForEmbed = new MessageForEmbed(
"New Staff Application Submitted",
"Join date: " + (application.joinDate() != null ? application.joinDate().toString() : "unknown") +
"\nSubmitted: " + formatInstant(timestamp),
"\nSubmitted: " + formatInstant(timestamp),
fields,
null,
timestamp,
null
);
null);
DiscordSender.getInstance().sendEmbedWithThreadToChannels(channelIds, messageForEmbed, "Staff Application");
}
private String safe(String s) {