Skip to content

Add custom .equals for CommandData and OptionData #3008

@annpocoyo

Description

@annpocoyo

General Troubleshooting

  • I have checked for similar issues on the Issue-tracker.
  • I have updated to the latest JDA version
  • I have checked the branches or the maintainers' PRs for upcoming features.

Feature Request

Add a custom .equals method for CommandData and OptionData. This .equals method would check if the two commands are pretty much the same.

It would do this by comparing the name, description, type (for options), required? (for options) and OptionData list (for commands).

Example Use-Case

// Snippet of code that *could* work
LOGGER.info("Got existing commands");
            for (Command discordCommand : registeredCommands) {
                SlashCommandData discordCommandData = SlashCommandData.fromCommand(discordCommand);
                if (!commands.remove(discordCommandData)) {
                    if (commands.stream().noneMatch(command -> command.getName().equals(discordCommand.getName()))) {
                        discordCommand.delete().queue();
                        LOGGER.info("Sent request to delete no longer existing command {}", discordCommand.getName());
                    }
                } else {
                    LOGGER.info("Command {} already up to date", discordCommand.getName());
                }
            }

            for (CommandData command : commands) {
                guild.upsertCommand(command).queue();
                LOGGER.info("Sent request to upsert command {}", command.getName());
            }
            LOGGER.info("Updated all commands");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions