Compare commits

...

12 Commits

Author SHA1 Message Date
Sheldan
4a3d43b1b0 [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
2025-07-13 19:45:59 +02:00
release-bot
15d41c58ef Commit from GitHub Actions (Publishes a new version of abstracto) 2025-05-29 20:16:51 +00:00
release-bot
ad863af5d6 [maven-release-plugin] prepare for next development iteration 2025-05-29 20:05:41 +00:00
release-bot
f3dae2f6a3 [maven-release-plugin] prepare release v1.6.8 2025-05-29 20:05:40 +00:00
Sheldan
9f9c0612eb [AB-xxx] fixing youtube sometimes not returning videos even if specified 2025-05-29 22:00:45 +02:00
Sheldan
db73071a71 [AB-xxx] updating JDA version 2025-04-26 13:11:36 +02:00
Sheldan
d7125fbf25 [AB-xxx] adding input to response model for 8ball and choose command 2025-04-26 13:09:34 +02:00
release-bot
fd3bf41406 Commit from GitHub Actions (Publishes a new version of abstracto) 2025-04-01 11:47:09 +00:00
release-bot
d1abe194ec [maven-release-plugin] prepare for next development iteration 2025-04-01 11:37:04 +00:00
release-bot
79477923c6 [maven-release-plugin] prepare release v1.6.7 2025-04-01 11:37:03 +00:00
Sheldan
be9ffa3045 [AB-xxx] updating postgres driver version 2025-04-01 13:34:34 +02:00
release-bot
e29ceb9243 [maven-release-plugin] prepare for next development iteration 2025-03-31 21:49:19 +00:00
140 changed files with 1033 additions and 381 deletions

2
.env
View File

@@ -1,2 +1,2 @@
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/ REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.6.4 VERSION=1.6.8

View File

@@ -11,7 +11,7 @@ This repository does not provide the full functionality in order to start a disc
## Technologies ## Technologies
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 5.3.1 * [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 5.4.0
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including dependency injection and more) * [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including dependency injection and more)
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA. * [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
* [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration. * [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration.

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>anti-raid</artifactId> <artifactId>anti-raid</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>anti-raid</artifactId> <artifactId>anti-raid</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles</artifactId> <artifactId>assignable-roles</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

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.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.emoji.CustomEmoji; import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
import net.dv8tion.jda.api.entities.emoji.Emoji; 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.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles</artifactId> <artifactId>assignable-roles</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>assignable-roles-int</artifactId> <artifactId>assignable-roles-int</artifactId>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>custom-command</artifactId> <artifactId>custom-command</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>custom-command</artifactId> <artifactId>custom-command</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>dynamic-activity</artifactId> <artifactId>dynamic-activity</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>dynamic-activity</artifactId> <artifactId>dynamic-activity</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>entertainment</artifactId> <artifactId>entertainment</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -52,6 +52,7 @@ public class Choose extends AbstractConditionableCommand {
String choice = entertainmentService.takeChoice(choices, commandContext.getAuthor()); String choice = entertainmentService.takeChoice(choices, commandContext.getAuthor());
ChooseResponseModel responseModel = ChooseResponseModel ChooseResponseModel responseModel = ChooseResponseModel
.builder() .builder()
.choices(choices)
.chosenValue(choice) .chosenValue(choice)
.build(); .build();
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel())) return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel()))
@@ -70,6 +71,7 @@ public class Choose extends AbstractConditionableCommand {
String choice = entertainmentService.takeChoice(choices, event.getMember()); String choice = entertainmentService.takeChoice(choices, event.getMember());
ChooseResponseModel responseModel = ChooseResponseModel ChooseResponseModel responseModel = ChooseResponseModel
.builder() .builder()
.choices(choices)
.chosenValue(choice) .chosenValue(choice)
.build(); .build();
return interactionService.replyEmbed(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, event) return interactionService.replyEmbed(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, event)

View File

@@ -56,6 +56,7 @@ public class EightBall extends AbstractConditionableCommand {
String chosenKey = entertainmentService.getEightBallValue(text); String chosenKey = entertainmentService.getEightBallValue(text);
EightBallResponseModel responseModel = EightBallResponseModel EightBallResponseModel responseModel = EightBallResponseModel
.builder() .builder()
.input(text)
.chosenKey(chosenKey) .chosenKey(chosenKey)
.build(); .build();
return templateService.renderEmbedTemplate(EIGHT_BALL_RESPONSE_TEMPLATE_KEY, responseModel, serverId); return templateService.renderEmbedTemplate(EIGHT_BALL_RESPONSE_TEMPLATE_KEY, responseModel, serverId);

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>entertainment</artifactId> <artifactId>entertainment</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -1,5 +1,6 @@
package dev.sheldan.abstracto.entertainment.model.command; package dev.sheldan.abstracto.entertainment.model.command;
import java.util.List;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -9,4 +10,5 @@ import lombok.Setter;
@Builder @Builder
public class ChooseResponseModel { public class ChooseResponseModel {
private String chosenValue; private String chosenValue;
private List<String> choices;
} }

View File

@@ -9,4 +9,5 @@ import lombok.Setter;
@Builder @Builder
public class EightBallResponseModel { public class EightBallResponseModel {
private String chosenKey; private String chosenKey;
private String input;
} }

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>experience-tracking</artifactId> <artifactId>experience-tracking</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>experience-tracking</artifactId> <artifactId>experience-tracking</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>giveaway</artifactId> <artifactId>giveaway</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>giveaway-impl</artifactId> <artifactId>giveaway-impl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>giveaway</artifactId> <artifactId>giveaway</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>giveaway-int</artifactId> <artifactId>giveaway-int</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>giveaway</artifactId> <artifactId>giveaway</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>image-generation</artifactId> <artifactId>image-generation</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>image-generation-impl</artifactId> <artifactId>image-generation-impl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>image-generation</artifactId> <artifactId>image-generation</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>image-generation-int</artifactId> <artifactId>image-generation-int</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>image-generation</artifactId> <artifactId>image-generation</artifactId>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>invite-filter</artifactId> <artifactId>invite-filter</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>invite-filter</artifactId> <artifactId>invite-filter</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation-int</artifactId> <artifactId>moderation-int</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>link-embed</artifactId> <artifactId>link-embed</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -357,7 +357,9 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
private Boolean shouldMentionReferencedAuthor(Message message) { private Boolean shouldMentionReferencedAuthor(Message message) {
if(message.getReferencedMessage() != null) { 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; return false;
} }

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>link-embed</artifactId> <artifactId>link-embed</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>logging</artifactId> <artifactId>logging</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>logging</artifactId> <artifactId>logging</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation</artifactId> <artifactId>moderation</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation</artifactId> <artifactId>moderation</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>modmail</artifactId> <artifactId>modmail</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>modmail</artifactId> <artifactId>modmail</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto</groupId> <groupId>dev.sheldan.abstracto</groupId>
<artifactId>abstracto-application</artifactId> <artifactId>abstracto-application</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>profanity-filter</artifactId> <artifactId>profanity-filter</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>profanity-filter</artifactId> <artifactId>profanity-filter</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>remind</artifactId> <artifactId>remind</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>remind</artifactId> <artifactId>remind</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>repost-detection</artifactId> <artifactId>repost-detection</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>repost-detection</artifactId> <artifactId>repost-detection</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>starboard</artifactId> <artifactId>starboard</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -138,8 +138,12 @@ public abstract class StarboardListener {
protected void updateStarboardPost(CachedMessage message, AUserInAServer userReacting, boolean adding, StarboardPost starboardPost, List<AUserInAServer> userExceptAuthor) { protected void updateStarboardPost(CachedMessage message, AUserInAServer userReacting, boolean adding, StarboardPost starboardPost, List<AUserInAServer> userExceptAuthor) {
starboardPost.setIgnored(false); 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) { if(adding) {
log.debug("Adding reactor {} from message {}", userReacting.getUserReference().getId(), message.getMessageId()); log.debug("Adding reactor {} from message {}", userReacting.getUserReference().getId(), message.getMessageId());
starboardPostReactorManagementService.addReactor(starboardPost, userReacting); starboardPostReactorManagementService.addReactor(starboardPost, userReacting);

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>starboard</artifactId> <artifactId>starboard</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>statistic</artifactId> <artifactId>statistic</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>statistic</artifactId> <artifactId>statistic</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>sticky-roles</artifactId> <artifactId>sticky-roles</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>sticky-roles-impl</artifactId> <artifactId>sticky-roles-impl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>sticky-roles</artifactId> <artifactId>sticky-roles</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<artifactId>sticky-roles-int</artifactId> <artifactId>sticky-roles-int</artifactId>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>suggestion</artifactId> <artifactId>suggestion</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>suggestion</artifactId> <artifactId>suggestion</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>twitch</artifactId> <artifactId>twitch</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>twitch</artifactId> <artifactId>twitch</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility</artifactId> <artifactId>utility</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility</artifactId> <artifactId>utility</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>voice-channel-context</artifactId> <artifactId>voice-channel-context</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>voice-channel-context</artifactId> <artifactId>voice-channel-context</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>abstracto-modules</artifactId> <artifactId>abstracto-modules</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>webservices</artifactId> <artifactId>webservices</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -26,7 +26,7 @@ public class YoutubeSearchServiceBean implements YoutubeSearchService {
@Override @Override
public YoutubeVideo searchOneVideoForQuery(String query) { public YoutubeVideo searchOneVideoForQuery(String query) {
try { try {
YouTube.Search.List search = youTube.search().list("id,snippet"); YouTube.Search.List search = youTube.search().list("id");
search.setQ(query); search.setQ(query);
search.setType("video"); search.setType("video");
search.setMaxResults(1L); search.setMaxResults(1L);
@@ -35,6 +35,9 @@ public class YoutubeSearchServiceBean implements YoutubeSearchService {
if(items.isEmpty()) { if(items.isEmpty()) {
throw new YoutubeVideoNotFoundException(); throw new YoutubeVideoNotFoundException();
} }
if(items.stream().noneMatch(searchResult -> searchResult.getId().get("kind").equals("youtube#video"))) {
throw new YoutubeVideoNotFoundException();
}
return youtubeVideoService.getVideoInfo(items.get(0).getId().getVideoId()); return youtubeVideoService.getVideoInfo(items.get(0).getId().getVideoId());
} catch (IOException e) { } catch (IOException e) {
throw new YoutubeAPIException(e); throw new YoutubeAPIException(e);

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.modules</groupId> <groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>webservices</artifactId> <artifactId>webservices</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto</groupId> <groupId>dev.sheldan.abstracto</groupId>
<artifactId>abstracto-application</artifactId> <artifactId>abstracto-application</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>dev.sheldan.abstracto.core</groupId> <groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>1.6.6</version> <version>1.6.9-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging> <packaging>jar</packaging>
@@ -84,7 +84,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>io.github.freya022</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<exclusions> <exclusions>
<exclusion> <exclusion>
@@ -131,6 +131,11 @@
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.danilopianini</groupId>
<artifactId>gson-extras</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>

View File

@@ -3,9 +3,25 @@ package dev.sheldan.abstracto.core.config;
import ch.qos.logback.core.net.ssl.SecureRandomFactoryBean; import ch.qos.logback.core.net.ssl.SecureRandomFactoryBean;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.typeadapters.RuntimeTypeAdapterFactory;
import dev.sheldan.abstracto.core.logging.OkHttpLogger; import dev.sheldan.abstracto.core.logging.OkHttpLogger;
import dev.sheldan.abstracto.core.metric.OkHttpMetrics; import dev.sheldan.abstracto.core.metric.OkHttpMetrics;
import dev.sheldan.abstracto.core.service.BotService; import dev.sheldan.abstracto.core.service.BotService;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ActionRowButtonConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ActionRowItemConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ComponentConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionAccessoryConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionButton;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionComponentConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionTextDisplay;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.SectionThumbnail;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelActionRowConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelContainerConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelFileConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelMediaGalleryConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelSectionConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelSeperatorConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.TopLevelTextDisplay;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -41,6 +57,27 @@ public class CoreConfig {
GsonBuilder builder = new GsonBuilder() GsonBuilder builder = new GsonBuilder()
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter()) .registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter())
.registerTypeAdapter(Instant.class, new InstantAdapter()) .registerTypeAdapter(Instant.class, new InstantAdapter())
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
.of(ComponentConfig.class, "type")
.registerSubtype(TopLevelActionRowConfig.class, "actionRow")
.registerSubtype(TopLevelSectionConfig.class, "section")
.registerSubtype(TopLevelFileConfig.class, "fileDisplay")
.registerSubtype(TopLevelMediaGalleryConfig.class, "mediaGallery")
.registerSubtype(TopLevelSeperatorConfig.class, "separator")
.registerSubtype(TopLevelContainerConfig.class, "container")
.registerSubtype(TopLevelTextDisplay.class, "textDisplay"))
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
.of(ActionRowItemConfig.class, "type")
.registerSubtype(ActionRowButtonConfig.class, "button"))
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
.of(SectionAccessoryConfig.class, "type")
.registerSubtype(SectionButton.class, "button")
.registerSubtype(SectionThumbnail.class, "thumbnail")
)
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory
.of(SectionComponentConfig.class, "type")
.registerSubtype(SectionTextDisplay.class, "textDisplay")
)
.setPrettyPrinting(); .setPrettyPrinting();
if(customJsonDeSerializers != null) { if(customJsonDeSerializers != null) {
customJsonDeSerializers.forEach(customJsonSerializer -> customJsonDeSerializers.forEach(customJsonSerializer ->

View File

@@ -6,10 +6,10 @@ import dev.sheldan.abstracto.core.service.MessageService;
import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.interactions.components.ActionComponent; import net.dv8tion.jda.api.components.ActionComponent;
import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; import net.dv8tion.jda.api.components.buttons.ButtonStyle;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -50,7 +50,7 @@ public class ComponentServiceBean implements ComponentService {
} else { } else {
ActionRow lastRow = message.getActionRows().get(message.getActionRows().size() - 1); ActionRow lastRow = message.getActionRows().get(message.getActionRows().size() - 1);
if(lastRow.getComponents().size() < MAX_BUTTONS_PER_ROW) { if(lastRow.getComponents().size() < MAX_BUTTONS_PER_ROW) {
lastRow.getComponents().add(button); lastRow.getButtons().add(button);
actionRows = message.getActionRows(); actionRows = message.getActionRows();
} else { } else {
List<ActionRow> currentActionRows = new ArrayList<>(message.getActionRows()); List<ActionRow> currentActionRows = new ArrayList<>(message.getActionRows());
@@ -86,7 +86,7 @@ public class ComponentServiceBean implements ComponentService {
public CompletableFuture<Void> removeComponentWithId(Message message, String componentId, Boolean rearrange) { public CompletableFuture<Void> removeComponentWithId(Message message, String componentId, Boolean rearrange) {
List<ActionRow> actionRows = new ArrayList<>(); List<ActionRow> actionRows = new ArrayList<>();
if(Boolean.TRUE.equals(rearrange)) { if(Boolean.TRUE.equals(rearrange)) {
List<net.dv8tion.jda.api.interactions.components.ActionComponent> components = new ArrayList<>(); List<net.dv8tion.jda.api.components.ActionComponent> components = new ArrayList<>();
message.getActionRows().forEach(row -> message.getActionRows().forEach(row ->
row row
.getComponents() .getComponents()
@@ -112,8 +112,8 @@ public class ComponentServiceBean implements ComponentService {
} }
@Override @Override
public List<ActionRow> splitIntoActionRowsMax(List<net.dv8tion.jda.api.interactions.components.ActionComponent> allComponents) { public List<ActionRow> splitIntoActionRowsMax(List<net.dv8tion.jda.api.components.ActionComponent> allComponents) {
List<List<net.dv8tion.jda.api.interactions.components.ActionComponent>> actionRows = ListUtils.partition(allComponents, MAX_BUTTONS_PER_ROW); List<List<net.dv8tion.jda.api.components.ActionComponent>> actionRows = ListUtils.partition(allComponents, MAX_BUTTONS_PER_ROW);
return actionRows.stream().map(ActionRow::of).collect(Collectors.toList()); return actionRows.stream().map(ActionRow::of).collect(Collectors.toList());
} }

View File

@@ -17,8 +17,8 @@ import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.interactions.Interaction; import net.dv8tion.jda.api.interactions.Interaction;
import net.dv8tion.jda.api.interactions.InteractionHook; import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.components.ActionComponent; import net.dv8tion.jda.api.components.ActionComponent;
import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction; import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction;
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction; import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction; import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
@@ -260,56 +260,57 @@ public class InteractionServiceBean implements InteractionService {
public CompletableFuture<InteractionHook> replyMessageToSend(MessageToSend messageToSend, IReplyCallback callback) { public CompletableFuture<InteractionHook> replyMessageToSend(MessageToSend messageToSend, IReplyCallback callback) {
ReplyCallbackAction action = null; ReplyCallbackAction action = null;
if(messageToSend.getMessages() != null && !messageToSend.getMessages().isEmpty()) { if(messageToSend.getUseComponentsV2()) {
metricService.incrementCounter(MESSAGE_SEND_METRIC); action = callback.replyComponents(messageToSend.getComponents()).useComponentsV2();
action = callback.reply(messageToSend.getMessages().get(0)); } else {
} if(messageToSend.getMessages() != null && !messageToSend.getMessages().isEmpty()) {
metricService.incrementCounter(MESSAGE_SEND_METRIC);
if(messageToSend.getEmbeds() != null && !messageToSend.getEmbeds().isEmpty()) { action = callback.reply(messageToSend.getMessages().get(0));
if(action != null) {
action = action.addEmbeds(messageToSend.getEmbeds().subList(0, Math.min(10, messageToSend.getEmbeds().size())));
} else {
action = callback.replyEmbeds(messageToSend.getEmbeds());
} }
} if(messageToSend.getEmbeds() != null && !messageToSend.getEmbeds().isEmpty()) {
if(action != null) {
if(messageToSend.hasFilesToSend()) { action = action.addEmbeds(messageToSend.getEmbeds().subList(0, Math.min(10, messageToSend.getEmbeds().size())));
List<FileUpload> attachedFiles = messageToSend } else {
action = callback.replyEmbeds(messageToSend.getEmbeds());
}
}
if(messageToSend.hasFilesToSend()) {
List<FileUpload> attachedFiles = messageToSend
.getAttachedFiles() .getAttachedFiles()
.stream() .stream()
.map(AttachedFile::convertToFileUpload) .map(AttachedFile::convertToFileUpload)
.collect(Collectors.toList()); .collect(Collectors.toList());
if(action != null) { if(action != null) {
action.setFiles(attachedFiles); action.setFiles(attachedFiles);
} else { } else {
metricService.incrementCounter(MESSAGE_SEND_METRIC); metricService.incrementCounter(MESSAGE_SEND_METRIC);
action = callback.replyFiles(attachedFiles); action = callback.replyFiles(attachedFiles);
}
}
// this should be last, because we are "faking" a message, by inserting a ., in case there has not been a reply yet
// we could also throw an exception, but we are allowing this to go through
List<ActionRow> actionRows = messageToSend.getActionRows();
if(actionRows != null && !actionRows.isEmpty()) {
if(action == null) {
action = callback.reply(".");
}
action = action.setComponents(actionRows);
AServer server;
if(ContextUtils.isGuildKnown(callback)) {
server = serverManagementService.loadServer(callback.getGuild().getIdLong());
} else {
server = null;
}
actionRows.forEach(components -> components.forEach(component -> {
if(component instanceof ActionComponent) {
String id = ((ActionComponent)component).getId();
MessageToSend.ComponentConfig payload = messageToSend.getComponentPayloads().get(id);
if(payload != null && payload.getPersistCallback()) {
componentPayloadManagementService.createPayload(id, payload.getPayload(), payload.getPayloadType(), payload.getComponentOrigin(), server, payload.getComponentType());
}
} }
})); }
// this should be last, because we are "faking" a message, by inserting a ., in case there has not been a reply yet
// we could also throw an exception, but we are allowing this to go through
List<ActionRow> actionRows = messageToSend.getActionRows();
if(actionRows != null && !actionRows.isEmpty()) {
if(action == null) {
action = callback.reply(".");
}
action = action.setComponents(actionRows);
AServer server;
if(ContextUtils.isGuildKnown(callback)) {
server = serverManagementService.loadServer(callback.getGuild().getIdLong());
} else {
server = null;
}
actionRows.forEach(components -> components.forEach(component -> {
if(component instanceof ActionComponent) {
String id = ((ActionComponent)component).getId();
MessageToSend.ComponentConfig payload = messageToSend.getComponentPayloads().get(id);
if(payload != null && payload.getPersistCallback()) {
componentPayloadManagementService.createPayload(id, payload.getPayload(), payload.getPayloadType(), payload.getComponentOrigin(), server, payload.getComponentType());
}
}
}));
}
} }
if(messageToSend.getEphemeral()) { if(messageToSend.getEphemeral()) {
@@ -328,7 +329,7 @@ public class InteractionServiceBean implements InteractionService {
if(ContextUtils.isGuildKnown(callback)) { if(ContextUtils.isGuildKnown(callback)) {
Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(callback.getMessageChannel(), messageToSend); Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(callback.getMessageChannel(), messageToSend);
if (action != null) { if (action != null) {
action.setAllowedMentions(allowedMentions); action = action.setAllowedMentions(allowedMentions);
} }
} }

View File

@@ -8,9 +8,9 @@ import dev.sheldan.abstracto.core.interaction.modal.config.TextInputComponentSty
import dev.sheldan.abstracto.core.templating.service.TemplateService; import dev.sheldan.abstracto.core.templating.service.TemplateService;
import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.interactions.components.ItemComponent; import net.dv8tion.jda.api.interactions.components.ItemComponent;
import net.dv8tion.jda.api.interactions.components.text.TextInput; import net.dv8tion.jda.api.components.textinput.TextInput;
import net.dv8tion.jda.api.interactions.modals.Modal; import net.dv8tion.jda.api.interactions.modals.Modal;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@@ -1,7 +1,7 @@
package dev.sheldan.abstracto.core.interaction.modal.config; package dev.sheldan.abstracto.core.interaction.modal.config;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle; import net.dv8tion.jda.api.components.textinput.TextInputStyle;
public enum TextInputComponentStyle { public enum TextInputComponentStyle {
@SerializedName("short") @SerializedName("short")

View File

@@ -125,14 +125,26 @@ public class AllowedMentionServiceBean implements AllowedMentionService {
} }
if(messageToSend != null && messageToSend.getMessageConfig() != null) { if(messageToSend != null && messageToSend.getMessageConfig() != null) {
MessageConfig messageConfig = messageToSend.getMessageConfig(); MessageConfig messageConfig = messageToSend.getMessageConfig();
if(messageConfig.isAllowsEveryoneMention()) { if(messageConfig.getAllowsEveryoneMention() != null) {
allowedMentions.add(Message.MentionType.EVERYONE); if(messageConfig.getAllowsEveryoneMention()) {
allowedMentions.add(Message.MentionType.EVERYONE);
} else {
allowedMentions.remove(Message.MentionType.EVERYONE);
}
} }
if(messageConfig.isAllowsUserMention()) { if(messageConfig.getAllowsUserMention() != null) {
allowedMentions.add(Message.MentionType.USER); if(messageConfig.getAllowsUserMention()) {
allowedMentions.add(Message.MentionType.USER);
} else {
allowedMentions.remove(Message.MentionType.USER);
}
} }
if(messageConfig.isAllowsRoleMention()) { if(messageConfig.getAllowsRoleMention() != null) {
allowedMentions.add(Message.MentionType.ROLE); if(messageConfig.getAllowsRoleMention()) {
allowedMentions.add(Message.MentionType.ROLE);
} else {
allowedMentions.remove(Message.MentionType.ROLE);
}
} }
} }
return allowedMentions; return allowedMentions;

View File

@@ -74,6 +74,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
.fileName(attachment.getFileName()) .fileName(attachment.getFileName())
.height(attachment.getHeight()) .height(attachment.getHeight())
.spoiler(attachment.isSpoiler()) .spoiler(attachment.isSpoiler())
.contentType(attachment.getContentType())
.proxyUrl(attachment.getProxyUrl()) .proxyUrl(attachment.getProxyUrl())
.size(attachment.getSize()) .size(attachment.getSize())
.url(attachment.getUrl()) .url(attachment.getUrl())

View File

@@ -17,6 +17,7 @@ import dev.sheldan.abstracto.core.utils.FileService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.components.actionrow.ActionRowChildComponent;
import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
import net.dv8tion.jda.api.entities.channel.concrete.Category; import net.dv8tion.jda.api.entities.channel.concrete.Category;
@@ -25,9 +26,8 @@ import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.interactions.components.ActionComponent; import net.dv8tion.jda.api.components.ActionComponent;
import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.interactions.components.ItemComponent;
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
import net.dv8tion.jda.api.requests.restaction.MessageEditAction; import net.dv8tion.jda.api.requests.restaction.MessageEditAction;
import net.dv8tion.jda.api.utils.FileUpload; import net.dv8tion.jda.api.utils.FileUpload;
@@ -221,91 +221,96 @@ public class ChannelServiceBean implements ChannelService {
} }
List<CompletableFuture<Message>> futures = new ArrayList<>(); List<CompletableFuture<Message>> futures = new ArrayList<>();
List<MessageCreateAction> allMessageActions = new ArrayList<>(); List<MessageCreateAction> allMessageActions = new ArrayList<>();
Iterator<MessageEmbed> embedIterator = messageToSend.getEmbeds().iterator(); if(messageToSend.getUseComponentsV2() && messageToSend.getComponents() != null && !messageToSend.getComponents().isEmpty()) {
for (int i = 0; i < messageToSend.getMessages().size(); i++) {
metricService.incrementCounter(MESSAGE_SEND_METRIC); metricService.incrementCounter(MESSAGE_SEND_METRIC);
String text = messageToSend.getMessages().get(i); allMessageActions.add(textChannel.sendMessageComponents(messageToSend.getComponents()).useComponentsV2());
} else {
Iterator<MessageEmbed> embedIterator = messageToSend.getEmbeds().iterator();
for (int i = 0; i < messageToSend.getMessages().size(); i++) {
metricService.incrementCounter(MESSAGE_SEND_METRIC);
String text = messageToSend.getMessages().get(i);
List<MessageEmbed> messageEmbeds = new ArrayList<>();
while(embedIterator.hasNext()) {
MessageEmbed embedToAdd = embedIterator.next();
if((currentEmbedLength(messageEmbeds) + embedToAdd.getLength()) >= MessageEmbed.EMBED_MAX_LENGTH_BOT) {
break;
}
messageEmbeds.add(embedToAdd);
embedIterator.remove();
}
MessageCreateAction messageAction = textChannel.sendMessage(text);
if(!messageEmbeds.isEmpty()) {
messageAction.setEmbeds(messageEmbeds);
}
allMessageActions.add(messageAction);
}
List<MessageEmbed> messageEmbeds = new ArrayList<>(); List<MessageEmbed> messageEmbeds = new ArrayList<>();
// reset the iterator, because if the if in the above while iterator loop applied, we already took it out from the iterator
// but we didnt add it yet, so it would be lost
embedIterator = messageToSend.getEmbeds().iterator();
while(embedIterator.hasNext()) { while(embedIterator.hasNext()) {
MessageEmbed embedToAdd = embedIterator.next(); MessageEmbed embedToAdd = embedIterator.next();
if((currentEmbedLength(messageEmbeds) + embedToAdd.getLength()) >= MessageEmbed.EMBED_MAX_LENGTH_BOT) { if((currentEmbedLength(messageEmbeds) + embedToAdd.getLength()) >= MessageEmbed.EMBED_MAX_LENGTH_BOT && !messageEmbeds.isEmpty()) {
break; allMessageActions.add(textChannel.sendMessageEmbeds(messageEmbeds));
metricService.incrementCounter(MESSAGE_SEND_METRIC);
messageEmbeds = new ArrayList<>();
} }
messageEmbeds.add(embedToAdd); messageEmbeds.add(embedToAdd);
embedIterator.remove();
} }
MessageCreateAction messageAction = textChannel.sendMessage(text);
if(!messageEmbeds.isEmpty()) { if(!messageEmbeds.isEmpty()) {
messageAction.setEmbeds(messageEmbeds);
}
allMessageActions.add(messageAction);
}
List<MessageEmbed> messageEmbeds = new ArrayList<>();
// reset the iterator, because if the if in the above while iterator loop applied, we already took it out from the iterator
// but we didnt add it yet, so it would be lost
embedIterator = messageToSend.getEmbeds().iterator();
while(embedIterator.hasNext()) {
MessageEmbed embedToAdd = embedIterator.next();
if((currentEmbedLength(messageEmbeds) + embedToAdd.getLength()) >= MessageEmbed.EMBED_MAX_LENGTH_BOT && !messageEmbeds.isEmpty()) {
allMessageActions.add(textChannel.sendMessageEmbeds(messageEmbeds)); allMessageActions.add(textChannel.sendMessageEmbeds(messageEmbeds));
metricService.incrementCounter(MESSAGE_SEND_METRIC); metricService.incrementCounter(MESSAGE_SEND_METRIC);
messageEmbeds = new ArrayList<>();
} }
messageEmbeds.add(embedToAdd);
}
if(!messageEmbeds.isEmpty()) { List<ActionRow> actionRows = messageToSend.getActionRows();
allMessageActions.add(textChannel.sendMessageEmbeds(messageEmbeds)); if(!actionRows.isEmpty()) {
metricService.incrementCounter(MESSAGE_SEND_METRIC); List<List<ActionRow>> groupedActionRows = ListUtils.partition(actionRows, ComponentService.MAX_BUTTONS_PER_ROW);
} for (int i = 0; i < allMessageActions.size(); i++) {
allMessageActions.set(i, allMessageActions.get(i).setComponents(groupedActionRows.get(i)));
List<ActionRow> actionRows = messageToSend.getActionRows(); }
if(!actionRows.isEmpty()) { for (int i = allMessageActions.size(); i < groupedActionRows.size(); i++) {
List<List<ActionRow>> groupedActionRows = ListUtils.partition(actionRows, ComponentService.MAX_BUTTONS_PER_ROW); // TODO maybe possible nicer
for (int i = 0; i < allMessageActions.size(); i++) { allMessageActions.add(textChannel.sendMessage(".").setComponents(groupedActionRows.get(i)));
allMessageActions.set(i, allMessageActions.get(i).setComponents(groupedActionRows.get(i))); }
} AServer server = null;
for (int i = allMessageActions.size(); i < groupedActionRows.size(); i++) { if(textChannel instanceof GuildChannel) {
// TODO maybe possible nicer GuildChannel channel = (GuildChannel) textChannel;
allMessageActions.add(textChannel.sendMessage(".").setComponents(groupedActionRows.get(i))); server = serverManagementService.loadServer(channel.getGuild());
} }
AServer server = null; for (ActionRow row : actionRows) {
if(textChannel instanceof GuildChannel) { for (ActionRowChildComponent component : row) {
GuildChannel channel = (GuildChannel) textChannel; if (component instanceof ActionComponent) {
server = serverManagementService.loadServer(channel.getGuild()); String id = ((ActionComponent) component).getId();
} MessageToSend.ComponentConfig payload = messageToSend.getComponentPayloads().get(id);
for (ActionRow components : actionRows) { if (payload != null && payload.getPersistCallback()) {
for (ItemComponent component : components) { componentPayloadManagementService.createPayload(id, payload.getPayload(), payload.getPayloadType(), payload.getComponentOrigin(), server, payload.getComponentType());
if (component instanceof ActionComponent) { }
String id = ((ActionComponent) component).getId();
MessageToSend.ComponentConfig payload = messageToSend.getComponentPayloads().get(id);
if (payload != null && payload.getPersistCallback()) {
componentPayloadManagementService.createPayload(id, payload.getPayload(), payload.getPayloadType(), payload.getComponentOrigin(), server, payload.getComponentType());
} }
} }
} }
} }
}
if(messageToSend.hasFilesToSend()) { if(messageToSend.hasFilesToSend()) {
List<FileUpload> attachedFiles = messageToSend List<FileUpload> attachedFiles = messageToSend
.getAttachedFiles() .getAttachedFiles()
.stream() .stream()
.map(AttachedFile::convertToFileUpload) .map(AttachedFile::convertToFileUpload)
.collect(Collectors.toList()); .collect(Collectors.toList());
if(!allMessageActions.isEmpty()) { if(!allMessageActions.isEmpty()) {
// in case there has not been a message, we need to increment it // in case there has not been a message, we need to increment it
allMessageActions.set(0, allMessageActions.get(0).addFiles(attachedFiles)); allMessageActions.set(0, allMessageActions.get(0).addFiles(attachedFiles));
} else { } else {
metricService.incrementCounter(MESSAGE_SEND_METRIC); metricService.incrementCounter(MESSAGE_SEND_METRIC);
allMessageActions.add(textChannel.sendFiles(attachedFiles)); allMessageActions.add(textChannel.sendFiles(attachedFiles));
}
} }
} }
Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(textChannel, messageToSend); Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(textChannel, messageToSend);
allMessageActions.forEach(messageAction -> { allMessageActions.forEach(messageAction -> {
if(messageToSend.getReferencedMessageId() != null) { if(messageToSend.getReferencedMessageId() != null) {
messageAction = messageAction.setMessageReference(messageToSend.getReferencedMessageId()); messageAction = messageAction.setMessageReference(messageToSend.getReferencedMessageId());
if(messageToSend.getMessageConfig() != null && !messageToSend.getMessageConfig().isMentionsReferencedMessage()) { if(messageToSend.getMessageConfig() != null && !messageToSend.getMessageConfig().getMentionsReferencedMessage()) {
messageAction = messageAction.mentionRepliedUser(false); messageAction = messageAction.mentionRepliedUser(false);
} }
} }
@@ -337,6 +342,15 @@ public class ChannelServiceBean implements ChannelService {
@Override @Override
public CompletableFuture<Message> editMessageInAChannelFuture(MessageToSend messageToSend, MessageChannel channel, Long messageId) { public CompletableFuture<Message> editMessageInAChannelFuture(MessageToSend messageToSend, MessageChannel channel, Long messageId) {
MessageEditAction messageAction; MessageEditAction messageAction;
if(messageToSend.getUseComponentsV2()) {
Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(channel, messageToSend);
return channel
.editMessageComponentsById(messageId, messageToSend.getComponents())
.useComponentsV2()
.setReplace(true)
.setAllowedMentions(allowedMentions)
.submit();
}
if(!messageToSend.getMessages().isEmpty() && !StringUtils.isBlank(messageToSend.getMessages().get(0))) { if(!messageToSend.getMessages().isEmpty() && !StringUtils.isBlank(messageToSend.getMessages().get(0))) {
log.debug("Editing message {} with new text content.", messageId); log.debug("Editing message {} with new text content.", messageId);
messageAction = channel.editMessageById(messageId, messageToSend.getMessages().get(0)); messageAction = channel.editMessageById(messageId, messageToSend.getMessages().get(0));

View File

@@ -16,7 +16,7 @@ import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel; import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import net.dv8tion.jda.api.requests.restaction.MessageEditAction; import net.dv8tion.jda.api.requests.restaction.MessageEditAction;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -2,8 +2,6 @@ package dev.sheldan.abstracto.core.service;
import dev.sheldan.abstracto.core.config.FeatureConfig; import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.PostTargetEnum; import dev.sheldan.abstracto.core.config.PostTargetEnum;
import dev.sheldan.abstracto.core.exception.ChannelNotInGuildException;
import dev.sheldan.abstracto.core.exception.GuildNotFoundException;
import dev.sheldan.abstracto.core.exception.PostTargetNotUsableException; import dev.sheldan.abstracto.core.exception.PostTargetNotUsableException;
import dev.sheldan.abstracto.core.exception.PostTargetNotValidException; import dev.sheldan.abstracto.core.exception.PostTargetNotValidException;
import dev.sheldan.abstracto.core.models.database.AServer; import dev.sheldan.abstracto.core.models.database.AServer;
@@ -11,6 +9,7 @@ import dev.sheldan.abstracto.core.models.database.PostTarget;
import dev.sheldan.abstracto.core.service.management.DefaultPostTargetManagementService; import dev.sheldan.abstracto.core.service.management.DefaultPostTargetManagementService;
import dev.sheldan.abstracto.core.service.management.PostTargetManagement; import dev.sheldan.abstracto.core.service.management.PostTargetManagement;
import dev.sheldan.abstracto.core.templating.model.MessageToSend; import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
@@ -181,40 +180,65 @@ public class PostTargetServiceBean implements PostTargetService {
return getMessageChannelForPostTarget(target).map(messageChannel -> { return getMessageChannelForPostTarget(target).map(messageChannel -> {
CompletableFuture<Message> messageEditFuture = new CompletableFuture<>(); CompletableFuture<Message> messageEditFuture = new CompletableFuture<>();
futures.add(messageEditFuture); futures.add(messageEditFuture);
if (StringUtils.isBlank(messageToSend.getMessages().get(0).trim())) { if(messageToSend.getUseComponentsV2()) {
channelService.retrieveMessageInChannel(messageChannel, messageId).thenAccept(message -> { channelService.retrieveMessageInChannel(messageChannel, messageId).thenAccept(message -> {
log.debug("Editing existing message {} when upserting message embeds in channel {} in server {}.", log.debug("Editing existing message {} when upserting message embeds in channel {} in server {}.",
messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId()); messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId());
messageService.editMessage(message, messageToSend.getEmbeds().get(0)) channelService.editMessageInAChannelFuture(messageToSend, messageChannel, messageId)
.queue(messageEditFuture::complete, messageEditFuture::completeExceptionally); .thenAccept(messageEditFuture::complete)
.exceptionally(throwable -> {
messageEditFuture.completeExceptionally(throwable);
return null;
});
}).exceptionally(throwable -> { }).exceptionally(throwable -> {
log.debug("Creating new message when upserting message embeds for message {} in channel {} in server {}.", log.debug("Creating new message when upserting message embeds for message {} in channel {} in server {}.",
messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId()); messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId());
sendEmbedInPostTarget(messageToSend, target).get(0) List<CompletableFuture<Message>> messageFutures = channelService.sendMessageToSendToChannel(messageToSend, messageChannel);
.thenAccept(messageEditFuture::complete).exceptionally(innerThrowable -> { FutureUtils.toSingleFutureGeneric(messageFutures)
log.error("Failed to send message to create a message.", innerThrowable); .thenAccept(unused -> messageEditFuture.complete(futures.get(0).join()))
messageEditFuture.completeExceptionally(innerThrowable); .exceptionally(innerThrowable -> {
return null; log.error("Failed to send message to create a message.", innerThrowable);
}); messageEditFuture.completeExceptionally(innerThrowable);
return null;
});
return null; return null;
}); });
} else { } else {
channelService.retrieveMessageInChannel(messageChannel, messageId).thenAccept(message -> { if (StringUtils.isBlank(messageToSend.getMessages().get(0).trim())) {
log.debug("Editing existing message {} when upserting message in channel {} in server {}.", channelService.retrieveMessageInChannel(messageChannel, messageId).thenAccept(message -> {
log.debug("Editing existing message {} when upserting message embeds in channel {} in server {}.",
messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId()); messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId());
messageService.editMessage(message, messageToSend.getMessages().get(0), messageToSend.getEmbeds().get(0)) messageService.editMessage(message, messageToSend.getEmbeds().get(0))
.queue(messageEditFuture::complete, messageEditFuture::completeExceptionally); .queue(messageEditFuture::complete, messageEditFuture::completeExceptionally);
}).exceptionally(throwable -> { }).exceptionally(throwable -> {
log.debug("Creating new message when trying to upsert a message {} in channel {} in server {}.", log.debug("Creating new message when upserting message embeds for message {} in channel {} in server {}.",
messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId()); messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId());
sendEmbedInPostTarget(messageToSend, target).get(0) sendEmbedInPostTarget(messageToSend, target).get(0)
.thenAccept(messageEditFuture::complete).exceptionally(innerThrowable -> { .thenAccept(messageEditFuture::complete).exceptionally(innerThrowable -> {
log.error("Failed to send message to create a message.", innerThrowable); log.error("Failed to send message to create a message.", innerThrowable);
messageEditFuture.completeExceptionally(innerThrowable); messageEditFuture.completeExceptionally(innerThrowable);
return null; return null;
}); });
return null; return null;
}); });
} else {
channelService.retrieveMessageInChannel(messageChannel, messageId).thenAccept(message -> {
log.debug("Editing existing message {} when upserting message in channel {} in server {}.",
messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId());
messageService.editMessage(message, messageToSend.getMessages().get(0), messageToSend.getEmbeds().get(0))
.queue(messageEditFuture::complete, messageEditFuture::completeExceptionally);
}).exceptionally(throwable -> {
log.debug("Creating new message when trying to upsert a message {} in channel {} in server {}.",
messageId, messageChannel.getIdLong(), messageChannel.getGuild().getId());
sendEmbedInPostTarget(messageToSend, target).get(0)
.thenAccept(messageEditFuture::complete).exceptionally(innerThrowable -> {
log.error("Failed to send message to create a message.", innerThrowable);
messageEditFuture.completeExceptionally(innerThrowable);
return null;
});
return null;
});
}
} }
return futures; return futures;
}).orElse(Arrays.asList(CompletableFuture.completedFuture(null))); }).orElse(Arrays.asList(CompletableFuture.completedFuture(null)));

View File

@@ -1,5 +1,7 @@
package dev.sheldan.abstracto.core.templating.model; package dev.sheldan.abstracto.core.templating.model;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ButtonConfig;
import dev.sheldan.abstracto.core.templating.model.messagecomponents.ComponentConfig;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -15,6 +17,7 @@ import java.util.List;
@Builder @Builder
public class MessageConfiguration { public class MessageConfiguration {
private List<EmbedConfiguration> embeds; private List<EmbedConfiguration> embeds;
private List<ComponentConfig> components;
private Long referencedMessageId; private Long referencedMessageId;
/** /**
* The message which is posted along the {@link net.dv8tion.jda.api.entities.MessageEmbed} as a normal message. * The message which is posted along the {@link net.dv8tion.jda.api.entities.MessageEmbed} as a normal message.

View File

@@ -17,6 +17,8 @@ public class MetaMessageConfiguration {
@Builder.Default @Builder.Default
private boolean allowsUserMention = true; private boolean allowsUserMention = true;
@Builder.Default @Builder.Default
private boolean useComponentsV2 = false;
@Builder.Default
private boolean mentionsReferencedMessage = true; private boolean mentionsReferencedMessage = true;
private Integer messageLimit; private Integer messageLimit;

View File

@@ -0,0 +1,14 @@
package dev.sheldan.abstracto.core.templating.model.messagecomponents;
import lombok.Getter;
import lombok.experimental.SuperBuilder;
@Getter
@SuperBuilder
public class ActionRowButtonConfig extends ButtonConfig implements ActionRowItemConfig{
@Override
public ActionRowItemType getType() {
return ActionRowItemType.BUTTON;
}
}

View File

@@ -0,0 +1,12 @@
package dev.sheldan.abstracto.core.templating.model.messagecomponents;
import java.util.List;
import lombok.Getter;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@Getter
public class ActionRowConfig {
protected List<ActionRowItemConfig> actionRowItems;
}

View File

@@ -0,0 +1,18 @@
package dev.sheldan.abstracto.core.templating.model.messagecomponents;
import com.google.gson.annotations.SerializedName;
public interface ActionRowItemConfig {
ActionRowItemType getType();
enum ActionRowItemType {
@SerializedName("button")
BUTTON,
@SerializedName("stringSelectMenu")
STRING_SELECT_MENU,
@SerializedName("entitySelectMenu")
ENTITY_SELECT_MENU
}
}

Some files were not shown because too many files have changed in this diff Show More