Skip to content

Commit

Permalink
fix: unused private constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
christolis committed Feb 21, 2024
1 parent c8cb7a0 commit b910040
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,24 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;

import java.util.Objects;

/**
* Configuration for the cool messages board feature, see
* {@link org.togetherjava.tjbot.features.basic.CoolMessagesBoardManager}.
*/
@JsonRootName("coolMessagesConfig")
public final class CoolMessagesBoardConfig {
private final String boardChannelPattern;
private final int minimumReactions;

private CoolMessagesBoardConfig(
@JsonProperty(value = "minimumReactions", required = true) int minimumReactions,
@JsonProperty(value = "boardChannelPattern",
required = true) String boardChannelPattern) {
this.minimumReactions = minimumReactions;
this.boardChannelPattern = boardChannelPattern;
}

/**
* Gets the minimum amount of reactions needed for a message to be considered as a quote.
*
* @return the minimum amount of reactions
*/
public int getMinimumReactions() {
return minimumReactions;
}
public record CoolMessagesBoardConfig(
@JsonProperty(value = "minimumReactions", required = true) int minimumReactions,
@JsonProperty(value = "boardChannelPattern", required = true) String boardChannelPattern) {

/**
* Gets the REGEX pattern used to identify the quotes text channel
* Creates a CoolMessagesBoardConfig.
*
* @return the channel name pattern
* @param minimumReactions the minimum amount of reactions
* @param boardChannelPattern the pattern for the board channel
*/
public String getBoardChannelPattern() {
return boardChannelPattern;
public CoolMessagesBoardConfig {
Objects.requireNonNull(boardChannelPattern);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CoolMessagesBoardManager(Config config) {
this.config = config.getCoolMessagesConfig();

boardChannelNamePredicate =
Pattern.compile(this.config.getBoardChannelPattern()).asMatchPredicate();
Pattern.compile(this.config.boardChannelPattern()).asMatchPredicate();
}

@Override
Expand All @@ -54,7 +54,7 @@ public void onMessageReactionAdd(MessageReactionAddEvent event) {
return;
}

if (isCoolEmoji && originalReactionsCount + 1 >= config.getMinimumReactions()) {
if (isCoolEmoji && originalReactionsCount + 1 >= config.minimumReactions()) {
event.retrieveMessage()
.queue(message -> insertCoolMessage(boardChannel.orElseThrow(), message),
e -> logger.warn("Tried to retrieve cool message but got: {}",
Expand Down

0 comments on commit b910040

Please sign in to comment.