[AB-xxx] adding ability to define unique ids for components, a color of the container, disabled state for multiple components and spoiler for container

fixing reminder message not containing a link to the message anymore
This commit is contained in:
Sheldan
2025-07-19 23:56:06 +02:00
parent f513f8890b
commit cb9ab8f542
8 changed files with 67 additions and 4 deletions

View File

@@ -223,6 +223,9 @@ public class RemindServiceBean implements ReminderService {
.builder()
.reminderParticipants(participantsDisplays)
.reminderDisplay(reminderDisplay)
.serverId(reminder.getServer().getId())
.channelId(reminder.getChannel().getId())
.messageId(reminder.getMessageId())
.userDisplay(UserDisplay.fromUser(member.getUser()))
.duration(Duration.between(reminder.getReminderDate(), reminder.getTargetDate()))
.build();

View File

@@ -13,6 +13,7 @@ public class ButtonConfig {
private String id;
private String url;
private Boolean disabled;
private Integer uniqueId;
private String emoteMarkdown;
private ButtonStyleConfig buttonStyle;
private String buttonPayload;

View File

@@ -0,0 +1,20 @@
package dev.sheldan.abstracto.core.templating.model.messagecomponents;
import java.awt.Color;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Builder
@Getter
@Setter
public class ContainerColor {
private Integer r;
private Integer g;
private Integer b;
public Color toColor() {
return new Color(r, g, b);
}
}

View File

@@ -8,6 +8,10 @@ import lombok.experimental.SuperBuilder;
@Getter
public class ContainerConfig implements ComponentConfig {
private List<ComponentConfig> components;
private ContainerColor color;
private Integer uniqueId;
private Boolean spoiler;
private Boolean disabled;
@Override
public ComponentTypeConfig getType() {
return ComponentTypeConfig.CONTAINER;

View File

@@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder;
@Getter
public class MediaGalleryConfig implements ComponentConfig {
private List<ImageConfig> images;
private Integer uniqueId;
@Override
public ComponentTypeConfig getType() {
return ComponentTypeConfig.MEDIA_GALLERY;

View File

@@ -9,5 +9,7 @@ import lombok.experimental.SuperBuilder;
public class SectionConfig {
protected SectionAccessoryConfig accessory;
protected List<SectionComponentConfig> components;
private Boolean disabled;
private Integer uniqueId;
}

View File

@@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder;
public class SeparatorConfig implements ComponentConfig {
private Boolean divider;
private Spacing spacing;
private Integer uniqueId;
@Override
public ComponentTypeConfig getType() {
return ComponentTypeConfig.SEPARATOR;

View File

@@ -351,7 +351,14 @@ public class TemplateServiceBean implements TemplateService {
}
}
if(accessory != null) {
return Section.of(accessory, sectionComponents);
Section section = Section.of(accessory, sectionComponents);
if(sectionConfig.getDisabled() != null) {
section = section.withDisabled(sectionConfig.getDisabled());
}
if(sectionConfig.getUniqueId() != null) {
section = section.withUniqueId(sectionConfig.getUniqueId());
}
return section;
}
}
} else if(componentConfig instanceof TopLevelFileConfig fileConfig) {
@@ -380,11 +387,19 @@ public class TemplateServiceBean implements TemplateService {
}
galleryItems.add(item);
});
return MediaGallery.of(galleryItems);
MediaGallery gallery = MediaGallery.of(galleryItems);
if(mediaGalleryConfig.getUniqueId() != null) {
gallery = gallery.withUniqueId(mediaGalleryConfig.getUniqueId());
}
return gallery;
}
} else if(componentConfig instanceof TopLevelSeperatorConfig seperatorConfig) {
return Separator.create(seperatorConfig.getDivider(),
Separator separator = Separator.create(seperatorConfig.getDivider(),
Spacing.toSpacing(seperatorConfig.getSpacing()));
if(seperatorConfig.getUniqueId() != null) {
separator = separator.withUniqueId(seperatorConfig.getUniqueId());
}
return separator;
} else if(componentConfig instanceof TopLevelContainerConfig topLevelContainerConfig) {
List<ContainerChildComponent> childComponents = new ArrayList<>();
for (ComponentConfig containerComponent : topLevelContainerConfig.getComponents()) {
@@ -393,7 +408,20 @@ public class TemplateServiceBean implements TemplateService {
childComponents.add((ContainerChildComponent) createdComponent);
}
}
return Container.of(childComponents);
Container container = Container.of(childComponents);
if(topLevelContainerConfig.getColor() != null) {
container = container.withAccentColor(topLevelContainerConfig.getColor().toColor());
}
if(topLevelContainerConfig.getUniqueId() != null) {
container = container.withUniqueId(topLevelContainerConfig.getUniqueId());
}
if(topLevelContainerConfig.getDisabled() != null) {
container = container.withDisabled(topLevelContainerConfig.getDisabled());
}
if(topLevelContainerConfig.getSpoiler() != null) {
container = container.withSpoiler(topLevelContainerConfig.getSpoiler());
}
return container;
}
return null;
}
@@ -545,6 +573,9 @@ public class TemplateServiceBean implements TemplateService {
if (buttonConfig.getDisabled() != null) {
createdButton = createdButton.withDisabled(buttonConfig.getDisabled());
}
if(buttonConfig.getUniqueId() != null) {
createdButton = createdButton.withUniqueId(buttonConfig.getUniqueId());
}
return createdButton;
}