[AB-xxx] adding initial support for components v2

fixing issue with buttons which only provide an emoji
adding logging in case updating a starboard post goes wrong
This commit is contained in:
Sheldan
2025-05-29 21:35:08 +02:00
parent 15d41c58ef
commit 4a3d43b1b0
51 changed files with 934 additions and 291 deletions

View File

@@ -31,7 +31,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
import net.dv8tion.jda.api.components.buttons.ButtonStyle;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@@ -357,7 +357,9 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
private Boolean shouldMentionReferencedAuthor(Message message) {
if(message.getReferencedMessage() != null) {
return message.getMentions().getMentions(Message.MentionType.USER).contains(message.getReferencedMessage().getAuthor());
return message.getMentions().getMentions(Message.MentionType.USER)
.stream()
.anyMatch(user -> message.getReferencedMessage().getAuthor().getIdLong() == user.getIdLong());
}
return false;
}

View File

@@ -138,8 +138,12 @@ public abstract class StarboardListener {
protected void updateStarboardPost(CachedMessage message, AUserInAServer userReacting, boolean adding, StarboardPost starboardPost, List<AUserInAServer> userExceptAuthor) {
starboardPost.setIgnored(false);
// TODO handle futures correctly
starboardService.updateStarboardPost(starboardPost, message, userExceptAuthor);
starboardService.updateStarboardPost(starboardPost, message, userExceptAuthor)
.thenAccept(unused -> log.info("Updated starboard post."))
.exceptionally(throwable -> {
log.error("Failed to update starboard post.", throwable);
return null;
});
if(adding) {
log.debug("Adding reactor {} from message {}", userReacting.getUserReference().getId(), message.getMessageId());
starboardPostReactorManagementService.addReactor(starboardPost, userReacting);