-
-
Notifications
You must be signed in to change notification settings - Fork 104
Oofs and Lmaos Starboard #798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
application/src/main/java/org/togetherjava/tjbot/config/OofsAndLmaosConfig.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/OofsAndLmaosStarboard.java
Outdated
Show resolved
Hide resolved
| @JsonRootName("starboard") | ||
| public final class StarboardConfig { | ||
| private final String oofEmojiName; | ||
| private final String lmaoEmojiName; | ||
| private final long starboardChannelId; | ||
|
|
||
| @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) | ||
| public StarboardConfig( | ||
| @JsonProperty(value = "oofEmojiName", required = true) String oofEmojiName, | ||
| @JsonProperty(value = "lmaoEmojiName", required = true) String lmaoEmojiName, | ||
| @JsonProperty(value = "starboardChannelId", required = true) long starboardChannelId) { | ||
| this.oofEmojiName = oofEmojiName; | ||
| this.lmaoEmojiName = lmaoEmojiName; | ||
| this.starboardChannelId = starboardChannelId; | ||
| } | ||
|
|
||
| public String getOofEmojiName() { | ||
| return oofEmojiName; | ||
| } | ||
|
|
||
| public String getLmaoEmojiName() { | ||
| return lmaoEmojiName; | ||
| } | ||
|
|
||
| public long getStarboardChannelId() { | ||
| return starboardChannelId; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing javadoc
application/src/main/java/org/togetherjava/tjbot/features/basic/Starboard.java
Outdated
Show resolved
Hide resolved
|
|
||
| Guild guild = event.getGuild(); | ||
| GuildChannel channel = event.getGuildChannel(); | ||
| if (!config.getEmojiNames().contains(emojiName) || !guild.getPublicRole().hasPermission(channel, Permission.VIEW_CHANNEL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like this either needs a comment or should be moved into a well named method, so that its clear why we do this check
application/src/main/java/org/togetherjava/tjbot/features/basic/Starboard.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/basic/Starboard.java
Outdated
Show resolved
Hide resolved
| /** | ||
| * Gets the config for the Starboard | ||
| * | ||
| * @return the config of the Starboard | ||
| * */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shitty javadoc. improve. explain the feature. how would u explain ur grandma what the starboard feature does? or someone new to the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what we have used for getHelpSystemConfig so I thought I should do something similar, nevertheless, I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then that javadoc is bad as well (im aware that i wrote it 😆)
application/src/main/java/org/togetherjava/tjbot/config/StarboardConfig.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/config/StarboardConfig.java
Outdated
Show resolved
Hide resolved
|
Sonar lint fails because |
|
That is because you are not yet checking whether the constructor args are non-null. See the other configs and follow the pattern. |
|
This pull request is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days. |
|
I have been out of town since a few weeks that's why I couldn't contribute, I will resume working on this in a few days. |
2042867 to
1ae7a61
Compare
| Optional<TextChannel> starboardChannel = | ||
| guild.getTextChannelsByName(config.getChannelName(), false).stream().findFirst(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a minor thing, but personally I feel like it's much nicer to make helper methods for something like this.
Especially when classes get bigger, reading getStarBoardChannel I find much nicer.
So you don't have to change it, but maybe think about it next time, what you prefer.
| event.getChannel() | ||
| .retrieveMessageById(event.getMessageId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| event.getChannel() | |
| .retrieveMessageById(event.getMessageId()) | |
| event.retrieveMessage() |
| * | ||
| * @return the name of the channel with the starboard | ||
| */ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| @Override | ||
| public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) { | ||
| String emojiName = event.getReaction().getEmoji().asCustom().getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| String emojiName = event.getReaction().getEmoji().asCustom().getName(); | |
| String emojiName = event.getEmoji().asCustom().getName(); |
| GuildChannel channel = event.getGuildChannel(); | ||
| if (!config.getEmojiNames().contains(emojiName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything feels to cramped, think I mentioned this before.
Being able to distinguish sections is much harder if it's a long lap of text.
| User author = message.getAuthor(); | ||
| return new EmbedBuilder().setAuthor(author.getName(), null, author.getAvatarUrl()) | ||
| .setDescription(message.getContentDisplay()) | ||
| .build(); // Maybe set footer as reacted emoji? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd set the footer as the reacted emoji, and maybe just add timestamp? Always nice
And are you linking the original message? Doesn't seem to be the case, I'd certainly do that.
Either add the link to the footer (like the original starboard), or add a button or something.
| .queue(); | ||
| } | ||
|
|
||
| private boolean ignoreMessage(String emojiName, Guild guild, GuildChannel channel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private boolean ignoreMessage(String emojiName, Guild guild, GuildChannel channel) { | |
| private boolean shouldIgnoreMessage(String emojiName, Guild guild, GuildChannel channel) { |
|
This pull request is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days. |
Completes #781