Skip to content
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

Verbose logging triggers wrongly #13

Open
Phoenix-Starlight opened this issue Feb 12, 2024 · 2 comments
Open

Verbose logging triggers wrongly #13

Phoenix-Starlight opened this issue Feb 12, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Phoenix-Starlight
Copy link

Phoenix-Starlight commented Feb 12, 2024

Describe the bug
Verbose logging fires incorrectly and logs messages about methods not being annotated, even though they are annotated.

To Reproduce
Steps to reproduce the behavior:

  1. Create a slash command class
public class Ping {
    @HandleSlash(name = "ping", desc = "Ping the bot")
    public static void pingCommand(SlashCommandCreateEvent event) {
        event
            .getSlashCommandInteraction()
            .createImmediateResponder()
            .setContent("Pong!")
            .respond();
    }
}
  1. Enable verbose logging in KCommando configuration.
  2. Annotate with HandleSlash
  3. Execute the project
  4. See The skipped methods at bot_test.commands.slash.Ping: (They don't have any appropriate annotation)

Expected behavior
It shouldn't log this message unless it is wrong. (Not annotated)

Versions
Your current JDA, Reflections8 and KCommando versions.
Javacord 3.8.0
KCommando 5.1.0
Reflections8: N/A

@Phoenix-Starlight Phoenix-Starlight added the bug Something isn't working label Feb 12, 2024
@PillageDev
Copy link

If your message is saying something like this:
[19:48:55.885 INFO] KCommando -> The skipped methods at dev.tiertests.commands.cooldown.ManageCooldownCmd: hashCode,getClass,notify,notifyAll (They don't have any appropriate annotation)

It is because those methods are inherited from the java Object class, and the annotation is just seeing those too.

@PillageDev
Copy link

The simple fix would be to in the KInitalizer class add this check

if (annotationType == null) {
    if (KCommando.verbose) {
        if (!(method.getDeclaringClass() == Object.class)) {
            skippedMethods.add(method.getName());
        }
    }
    continue;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants