Skip to content

Add tophelpers command 🏆 #117

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

Closed
wants to merge 3 commits into from

Conversation

d3vel0per
Copy link
Contributor

Fixes #65

Copy link
Contributor

@illuminator3 illuminator3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also maybe put the things into a different gradle module?

@illuminator3 illuminator3 added the enhancement New feature or request label Sep 14, 2021
@Zabuzard Zabuzard added the new command Add a new command or group of commands to the bot label Sep 14, 2021
@Zabuzard Zabuzard added this to the Migrate existing commands milestone Sep 14, 2021
Copy link
Member

@Tais993 Tais993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for using longs for ID's!

@d3vel0per d3vel0per marked this pull request as draft September 17, 2021 14:07
@d3vel0per
Copy link
Contributor Author

Changed to draft. Should not be merged.
Waiting for a few other PR's to go in.

@Zabuzard
Copy link
Member

@d3vel0per Any news on this?

@d3vel0per
Copy link
Contributor Author

@d3vel0per Any news on this?

Yes, I am waiting for:
#119 - Separate thread pool for command system + AbstractCommand
#135 - Database migration and segregation of module

Since both will need merges at my end.

@Zabuzard Zabuzard added blocked This issue is currently blocked by another issue (see comments) priority: normal labels Sep 27, 2021
@marko-radosavljevic marko-radosavljevic mentioned this pull request Oct 13, 2021
@Zabuzard
Copy link
Member

Tell me if you need help with rebasing.

By the way, the database related things you have been waiting for with #135 found their way into develop already via different PRs. I am unblocking this.

@Zabuzard Zabuzard removed the blocked This issue is currently blocked by another issue (see comments) label Oct 14, 2021
@d3vel0per
Copy link
Contributor Author

Tell me if you need help with rebasing.

By the way, the database related things you have been waiting for with #135 found their way into develop already via different PRs. I am unblocking this.

Should be good. I will pick it up again.

@d3vel0per d3vel0per marked this pull request as ready for review October 20, 2021 08:45
@d3vel0per d3vel0per requested review from a team as code owners October 20, 2021 08:45
@java-coding-prodigy
Copy link
Contributor

We seem to be having some trouble with the formatting, I think we should wait till @I-Al-Istannen and @borgrel fix it.

@d3vel0per d3vel0per requested a review from Zabuzard October 22, 2021 05:42
Comment on lines 15 to 17
/**
* Listener responsible for persistence of text message metadata
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please elaborate a bit here what and when it stores.

@@ -0,0 +1,4 @@
/**
* This package contains non-user interactive event listeners
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing dot .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a link to JDAs addEventListener thing so that people understand what its about.

Comment on lines +11 to +23
private static final Pattern HELP_CHANNEL_PATTERN = Pattern.compile(".*\\Qhelp\\E.*");

private JDAUtils() {}

/**
* Checks if a provided channel is a help channel.
*
* @param textChannel provided channel.
* @return true if the provided channel is a help channel, false otherwise.
*/
public static boolean isAHelpChannel(TextChannel textChannel) {
return HELP_CHANNEL_PATTERN.matcher(textChannel.getName()).matches();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I think it might be better to move those helpers back into where you actually use them, into TopHelperCommand or similar.

Comment on lines 66 to 70
private static long getBoundedCountAsLong(OptionMapping count) {
return count == null ? MIN_COUNT : Math.min(count.getAsLong(), MAX_COUNT);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of silently accepting inputs outside of the range, I would explicitly check the range and give the user an ephemeral message back, telling them to use the command with values inside the range and stop the command.

});
}

private static long getBoundedCountAsLong(OptionMapping count) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NotNull

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ll need to cross check once again but I think it comes as null when not specified. It's one of the not required fields

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then @Nullable. Unless your context requires it to always exist.

@Zabuzard Zabuzard mentioned this pull request Oct 23, 2021
@illuminator3
Copy link
Contributor

Please put everything that doesn't need to be in the application module in its own module.

@Zabuzard
Copy link
Member

Please put everything that doesn't need to be in the application module in its own module.

U mean the whole command should be in its own module? We havent done that so far. Or what do you specifically mean in this PR?

import org.jetbrains.annotations.Nullable;
import org.jooq.Records;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.util.PresentationUtils;

import javax.annotation.ParametersAreNonnullByDefault;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not used javax.annotation yet. I would suggest to not use them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why? Why would we prefer a vendor specific annotation and I see no point putting @NotNull/@nullable annotations across each and every method that we write.
If we prefer non-standard third party annotations, its still fine but does it have an equivalent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation we are using is already in our dependencies. If you want to use this other annotation, please make sure that the dependencies cover it.

That said, for the null-checks it would probably be best to stick to one and not mix the millions of @NotNull annotations with each other.

I dont have a strong opinion here. Maybe get other opinions (@I-Al-Istannen )

Copy link
Member

@Tais993 Tais993 Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to side with Zabuzard.

Usage of @NotNull and @Nullable makes it clear what the arguments are.
When you look at the docs of a method, it actually shows the arguments can't be null or are nullable. (Because it displays the method signature)
If you use a class-wide annotation like this it's not shown in the docs either.

If we prefer non-standard third party annotations, its still fine but does it have an equivalent?

To my knowledge, javax annotations have been removed since Java 11, so this argument is obsolete.

import org.jetbrains.annotations.Nullable;
import org.jooq.Records;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.util.PresentationUtils;

import javax.annotation.ParametersAreNonnullByDefault;
Copy link
Member

@Tais993 Tais993 Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to side with Zabuzard.

Usage of @NotNull and @Nullable makes it clear what the arguments are.
When you look at the docs of a method, it actually shows the arguments can't be null or are nullable. (Because it displays the method signature)
If you use a class-wide annotation like this it's not shown in the docs either.

If we prefer non-standard third party annotations, its still fine but does it have an equivalent?

To my knowledge, javax annotations have been removed since Java 11, so this argument is obsolete.


public final class TopHelpers extends SlashCommandAdapter {

private static final String COUNT_OPTION = "count";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zabuzard is also referring to the variable's name if I understand it correctly

Comment on lines +15 to +17
public final class PresentationUtils {
private PresentationUtils() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He said "or"

So, why did you ignore his second statement?

private static final long MIN_COUNT = 10L;
private static final long MAX_COUNT = 30L;

private record TopHelperRow(Integer serialId, Long userId, Long messageCount) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the primitives instead

@Zabuzard
Copy link
Member

Zabuzard commented Nov 7, 2021

@d3vel0per How is it going? Still planning on finishing this? Otherwise, should we maybe assign it to someone else to help out? (no hurry though)

@CLAassistant
Copy link

CLAassistant commented Nov 15, 2021

CLA assistant check
All committers have signed the CLA.

@Zabuzard
Copy link
Member

Seems @d3vel0per is a bit busy right now (which is totally fair). Unassigned. Someone else can take over, if wanted 👍

@marko-radosavljevic
Copy link
Contributor

Since origin branch of this PR is on a fork, people cannot work on it.

Moved to #282. ☺️

Thanks, @d3vel0per ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new command Add a new command or group of commands to the bot priority: normal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate TopHelper system
7 participants