File tree 3 files changed +12
-12
lines changed
application/src/main/java/org/togetherjava/tjbot
3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -364,7 +364,8 @@ public JShellConfig getJshell() {
364
364
public StarboardConfig getStarboard () {
365
365
return starboard ;
366
366
}
367
- /**
367
+
368
+ /**
368
369
* Gets the config for automatic pruning of helper roles.
369
370
*
370
371
* @return the configuration
Original file line number Diff line number Diff line change 8
8
import java .util .Objects ;
9
9
10
10
@ JsonRootName ("starboard" )
11
- public final class StarboardConfig {
12
- private final List <String > emojiNames ;
13
- private final String channelName ;
14
-
11
+ public record StarboardConfig (List <String > emojiNames , String channelName ) {
15
12
@ JsonCreator (mode = JsonCreator .Mode .PROPERTIES )
16
13
public StarboardConfig (
17
14
@ JsonProperty (value = "emojiNames" , required = true ) List <String > emojiNames ,
@@ -23,22 +20,24 @@ public StarboardConfig(
23
20
/**
24
21
* Gets the list of emotes that are recognized by the starboard feature. A message that is
25
22
* reacted on with an emote in this list will be reposted in a special channel.
26
- *
23
+ * <p>
27
24
* Empty to deactivate the feature.
28
25
*
29
26
* @return The List of emojis recognized by the starboard
30
27
*/
31
- public List <String > getEmojiNames () {
28
+ @ Override
29
+ public List <String > emojiNames () {
32
30
return emojiNames ;
33
31
}
34
32
35
33
/**
36
34
* Gets the name of the channel with the starboard Deactivate by using a non-existent channel
37
35
* name
38
- *
36
+ *
39
37
* @return the name of the channel with the starboard
40
38
*/
41
- public String getChannelName () {
39
+ @ Override
40
+ public String channelName () {
42
41
return channelName ;
43
42
}
44
43
}
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
44
44
Optional <TextChannel > starboardChannel = getStarboardChannel (guild );
45
45
if (starboardChannel .isEmpty ()) {
46
46
logger .warn ("There is no channel for the starboard in the guild with the name {}" ,
47
- config .getChannelName ());
47
+ config .channelName ());
48
48
return ;
49
49
}
50
50
if (database .read (context -> context .fetchExists (context .selectFrom (STARBOARD_MESSAGES )
@@ -59,12 +59,12 @@ public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
59
59
}
60
60
61
61
private boolean ignoreMessage (String emojiName , Guild guild , GuildChannel channel ) {
62
- return !config .getEmojiNames ().contains (emojiName )
62
+ return !config .emojiNames ().contains (emojiName )
63
63
|| !guild .getPublicRole ().hasPermission (channel , Permission .VIEW_CHANNEL );
64
64
}
65
65
66
66
private Optional <TextChannel > getStarboardChannel (Guild guild ) {
67
- return guild .getTextChannelsByName (config .getChannelName (), false ).stream ().findFirst ();
67
+ return guild .getTextChannelsByName (config .channelName (), false ).stream ().findFirst ();
68
68
}
69
69
70
70
private static MessageEmbed formEmbed (Message message ) {
You can’t perform that action at this time.
0 commit comments