Skip to content

Migration

Kaktushose edited this page Jan 31, 2022 · 2 revisions

Renamed Packages

The package com.github.kaktushose.jda.commands.entities has been split up into several packages. Below you can find a list with the new package sorted by class name:

JDA-Commands

  • com.github.kaktushose.jda.commands

EmbedCache and EmbedDTO

  • com.github.kaktushose.jda.commands.embeds

JsonEmbedFactory

  • com.github.kaktushose.jda.commands.embeds.error

  • com.github.kaktushose.jda.commands.embeds.help

CommandEvent

  • com.github.kaktushose.jda.commands.dispatching

Renamed Classes

  • The class EmbedFactory has been split up into HelpMessageFactory and ErrorMessageFactory

  • The class JsonEmbedFactory has been split up into JsonHelpMessageFactory and JsonErrorMessageFactory

Changed Functionality

JDACommands Building

new JDACommandsBuilder(jda).build();
JDACommands.start(jda, Main.class);

Json Embed Factory

builder.setEmbedFactory(new JsonEmbedFactory(new File("file.json")))
jdaCommands.getImplementationRegistry().setHelpMessageFactory(
        new JsonHelpMessageFactory(new EmbedCache("file.json"))
);
jdaCommands.getImplementationRegistry().setErrorMessageFactory(
        new JsonErrorMessageFactory(new EmbedCache("file.json"))
);

Guild Settings

jdaCommands.getDefaultSettings().setPrefix("?");
@Component
public class CustomSettingsProvider implements SettingsProvider {

    @Override
    public GuildSettings getSettings(@Nullable Guild guild) {
        return new GuildSettings().setPrefix("?");
    }

}

or, alternatively create a jdac.properties file inside the resources folder:

prefix=?

See the wiki for details.

Permissions

jdaCommands.getDefaultSettings().getPermissionHolders("moderator").add("id");
@Component
public class PermissionsService implements PermissionsProvider {

    @Override
    public boolean isMuted(@NotNull User user, @NotNull CommandContext context) {
        return false;
    }

    @Override
    public boolean hasPermission(@NotNull User user, @NotNull CommandContext context) {
        return user.getId().equals("id");
    }

    @Override
    public boolean hasPermission(@NotNull Member member, @NotNull CommandContext context) {
        return hasPermission(member.getUser(), context);
    }

See the wiki for details.