Skip to content

Conversation

illuminator3
Copy link
Contributor

image

Tais993 and others added 4 commits October 3, 2022 22:50
In BotCommandAdapter
the Interactor's name was used without prefix, but to forward from the button the prefix is needed.
@illuminator3 illuminator3 requested review from a team as code owners October 3, 2022 22:01
@illuminator3 illuminator3 self-assigned this Oct 3, 2022
@illuminator3 illuminator3 added enhance command Modify or improve an existing command or group of commands of the bot priority: low valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. labels Oct 3, 2022
@Zabuzard
Copy link
Member

Zabuzard commented Oct 4, 2022

Im confused. What is this? Is that for #594 ? If so, link it please. Also, that is already assigned to @Taz03 .

@Taz03
Copy link
Member

Taz03 commented Oct 4, 2022

Im confused. What is this? Is that for #594 ? If so, link it please. Also, that is already assigned to @Taz03 .

its a little different, the auto-complete provides option before the command usage, but lets say the user still writes and invalid id (which is possible) then the reply will contain some buttons for possible suggestions

@Zabuzard
Copy link
Member

Zabuzard commented Oct 4, 2022

i see. fair.

@illuminator3 illuminator3 requested a review from Zabuzard October 4, 2022 15:51
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Comment on lines 138 to 141
/**
* @return the component id generator used by {@link #generateComponentId(String...)} and
* {@link #generateComponentId(Lifespan, String...)}
*/
Copy link
Member

Choose a reason for hiding this comment

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

This is a core API class, it needs outstanding and full Javadoc.

Maybe write:

/**
 * Gets the generator used to create component IDs.
 * <p>
 * In general, prefer using {@link ...} and {@link ...} instead of interacting with the generator directly.
 *
 * @return the generator
 */ 

}

/**
* Sends the reply for a successfull /tag use (i.e. the given tag exists)
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

Comment on lines 70 to 71
private void sendTagReply(IReplyCallback callback, String userName, String tag,
@Nullable String commandString, @Nullable String replyToUser) {
Copy link
Member

Choose a reason for hiding this comment

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

I have some trouble with some variable names. Some of them dont really say what they are about.

  • callback - callback of what? I think it would be easier and more idiomatic if you just call it event (even if the type is a level higher).
  • its easy to confuse the two users that play a role here, since both are called "user". maybe keep userName, but rename replyToUser to replyTargetUser. if u want, rename userName to invokerUserName maybe, then its super clear.

}
message.queue();
.build())
.setContent(replyToUserOpt.orElse(""))
Copy link
Member

Choose a reason for hiding this comment

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

dont know the javadoc of setContent, but many JDA methods accept null. If thats the case, this could be a nice improvement, since u dont need the optional anymore then

.comparingInt(candidate -> StringDistances.editDistance(id, candidate)))
.limit(TAG_SUGGESTIONS_AMOUNT)
.toList();
List<List<String>> partition = ListUtils.partition(candidates, 5);
Copy link
Member

Choose a reason for hiding this comment

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

move that down a few lines, to where its used first

: ", did you perhaps mean any of the following?"))
.setEphemeral(true);

for (List<String> part : partition) {
Copy link
Member

Choose a reason for hiding this comment

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

naming issue: partition and partitions, would be easier to understand.

Or batch and batches


for (List<String> part : partition) {
action.addActionRow(part.stream()
.map(i -> Button.secondary(componentIdGenerator.generate(new ComponentId(
Copy link
Member

Choose a reason for hiding this comment

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

i is confusing, sounds like an index, but its actually the suggestion. please write it out

Comment on lines 96 to 101
.map(i -> Button.secondary(componentIdGenerator.generate(new ComponentId(
UserInteractorPrefix.getPrefixedNameFromClass(TagCommand.class, "tag"),
Arrays.asList(i,
userToReplyTo != null ? userToReplyTo.getAsUser().getAsMention()
: null)),
Lifespan.REGULAR), i))
Copy link
Member

Choose a reason for hiding this comment

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

This whole thing reads a bit complex, being nested in the map and loop. Id move this button creation out to a quick private helper method. sth like map(this::createSuggestionButton) or similar.

for (List<String> part : partition) {
action.addActionRow(part.stream()
.map(i -> Button.secondary(componentIdGenerator.generate(new ComponentId(
UserInteractorPrefix.getPrefixedNameFromClass(TagCommand.class, "tag"),
Copy link
Member

Choose a reason for hiding this comment

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

the usage of "tag" here is a bit dangerous. if someone renames the command, they will for sure forget to adjust it here as well.

try to link it somehow. either by giving it as method argument (like u did with the component ID genererator), or by having a constant between here and TagCommand.

* @return the generator
*/
protected final ComponentIdGenerator getComponentIdGenerator() {
protected final @Nullable ComponentIdGenerator getComponentIdGenerator() {
Copy link
Member

@Zabuzard Zabuzard Oct 6, 2022

Choose a reason for hiding this comment

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

the method is not supposed to return a nullable.

its a mistake to call the method before intiialization, not allowed. the method should fail-fast if its called before.

should probably also be added to its javadoc. thanks

@Taz03
Copy link
Member

Taz03 commented Jan 7, 2023

this pr is not valid anymore, we use auto-complete feature now, and while using this feature a user can only put the registered option, u can close this pr now

@illuminator3
Copy link
Contributor Author

thank you for appreciating all of the work I put into this already

@Tais993
Copy link
Member

Tais993 commented Jan 9, 2023

this pr is not valid anymore, we use auto-complete feature now, and while using this feature a user can only put the registered option, u can close this pr now

This is false, the user can still put any text that they want, autocomplete doesn't force anything.

@Zabuzard Zabuzard added stale and removed valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. labels Mar 6, 2023
@github-actions github-actions bot added the inactivity-closed Issues that have been closed due to inactivity, but are otherwise valid and might be reopened later label Mar 12, 2023
@github-actions github-actions bot closed this Mar 12, 2023
@illuminator3 illuminator3 added valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. and removed inactivity-closed Issues that have been closed due to inactivity, but are otherwise valid and might be reopened later labels Mar 12, 2023
@illuminator3 illuminator3 reopened this Mar 12, 2023
@github-actions github-actions bot removed the stale label Mar 13, 2023
@ankitsmt211 ankitsmt211 mentioned this pull request Nov 20, 2023
@ankitsmt211 ankitsmt211 added inactivity-closed Issues that have been closed due to inactivity, but are otherwise valid and might be reopened later and removed valid This issue/PR is validated and ready to be picked. This auto adds items to TJ project board. labels May 18, 2024
@ankitsmt211
Copy link
Member

This PR is being closed due to inactivity, can be opened later if need be.

@Zabuzard Zabuzard deleted the feature/tag-qol branch August 6, 2025 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhance command Modify or improve an existing command or group of commands of the bot inactivity-closed Issues that have been closed due to inactivity, but are otherwise valid and might be reopened later priority: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants