Skip to content
Olivia edited this page Jan 30, 2022 · 11 revisions

⚠️ This page is outdated! You are free to improve this by adding the new features Chewtils has to offer ⚠️


JDA-Chewtils adds a lot of changes that the original JDA-Utilities doesn't offer.
Many of these features are from open Pull requests towards the original project that haven't been merged yet and probably never will in the near future.

Menu.Builder().getItems() method

Method to return a list of items in a Menu.Builder() instance.
This is useful for figuring out if the list is empty or not.


Customizable "missing permission" Message for Commands

The "missing permission" message can, for the most part, be customized to fit the style of your bot better.


Corrected wording in the default error messages

Multiple phrases have been corrected to get rid of pointless capitalization or misworded stuff.

Changes:

Voice Channel   -> voice channel
Guild           -> server
Channel         -> channel
Direct messages -> direct messages

Fixes wrong boolean logic being used [JDA-Applications/JDA-Utilities#114]

This is a rather tiny change but still an important fix.


Adds EmbedPaginator to Menu module [JDA-Applications/JDA-Utilities#104]

The EmbedPaginator allows you to provide your own custom MessageEmbeds for pagination.


Checking user permissions before Bot permissions in commands

In JDA-Utilities would the permissions for the bot be checked first before the User permissions when both this.userPermissions and this.botPermissions were defined.
The logic was reversed so that user permissions will be checked before the bot even attempts to execute the command.


Multi-Prefix Support

Adds setPrefixes(String[]) to CommandClientBuilder to add more than 2 prefixes if needed. You should really never be needing more than 2, but in some cases, you might.

This also adds a getPrefix() method to Command. This returns whatever prefix was used to execute the command.


Adds setPrefixFunction method to CommandClientBuilder

The CommandClientBuilder now has a setPrefixFunction(Funktion<MessageReceivedEvent>) to allow you to provide a function (aka a lambda) as a valid prefix.
This allows you to have a much easier setup for a per-server, per-channel, per-user prefix or anything that depends on a specific value.

Example for a per-server prefix: [Source]

client.setPrefixFunction(event -> {
    if (event.isFromGuild()) {
        // Get server prefix, as long as it's cached.
        return ServerSettings.getServerIfCached(event.getGuild().getId()).getPrefix();
    }
    return null;
});

Ignore Cooldown when owner executes the command

The Command cooldown is now ignored when the Bot owner is executing a command.

If you, for whatever reason, still want to be subject to the cooldown, even as an owner, will you need to make your own cooldown logic or use an alt-account for testing.


Adds setCommandPreProcessFunction method to CommandClientBuilder

The setCommandPreProcessFunction(Function<MessageReceivedEvent>) in the CommandClientBuilder allows you to provide a Function (aka a lambda) to cancel command execution, if certain conditions don't match.

This can be useful for things such as a swear filter, where you don't want to execute the command if certain words are being used.

Example for a swear filter: [Source]

client.setCommandPreProcessFunction(event -> {
    if (SwearHandler.filteredMessages.contains(event.getMessage().getIdLong())) {
        return false;
    }
    return true;
});

Don't set Activity if null [JDA-Applications/JDA-Utilities#110]

JDA-Utilities always sets the Activity including when null is provided in which case the Activity will be disabled.
This is annoying and not needed if you set your own Activity, as it can cause an override and pointless extra Rest calls.

JDA-Chewtils adds this PR to not set the Activity at all, when null was provided (Default value).