feat(core): support root command deletion & standardize capabilities (#369)
This commit is contained in:
parent
08a97b2c4f
commit
28ff5d3003
14 changed files with 416 additions and 16 deletions
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.javacord;
|
||||
|
||||
import cloud.commandframework.CloudCapability;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
|
|
@ -77,6 +78,8 @@ public class JavacordCommandManager<C> extends CommandManager<C> {
|
|||
|
||||
this.commandPrefixMapper = commandPrefixMapper;
|
||||
this.commandPermissionMapper = commandPermissionMapper;
|
||||
|
||||
this.registerCapability(CloudCapability.StandardCapabilities.ROOT_COMMAND_DELETION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,10 +25,12 @@ package cloud.commandframework.javacord;
|
|||
|
||||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.StaticArgument;
|
||||
import cloud.commandframework.internal.CommandRegistrationHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.javacord.api.listener.message.MessageCreateListener;
|
||||
|
||||
final class JavacordRegistrationHandler<C> implements CommandRegistrationHandler {
|
||||
|
||||
|
|
@ -59,4 +61,15 @@ final class JavacordRegistrationHandler<C> implements CommandRegistrationHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterRootCommand(
|
||||
final @NonNull StaticArgument<?> rootCommand
|
||||
) {
|
||||
final JavacordCommand<C> command = this.registeredCommands.get(rootCommand);
|
||||
if (command == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.javacordCommandManager.getDiscordApi().removeListener(MessageCreateListener.class, command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.jda;
|
||||
|
||||
import cloud.commandframework.CloudCapability;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
|
|
@ -117,6 +118,9 @@ public class JDACommandManager<C> extends CommandManager<C> {
|
|||
new RoleArgument.RoleParser<>(
|
||||
new HashSet<>(Arrays.asList(RoleArgument.ParserMode.values()))
|
||||
));
|
||||
|
||||
// No "native" command system means that we can delete commands just fine.
|
||||
this.registerCapability(CloudCapability.StandardCapabilities.ROOT_COMMAND_DELETION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue