use of com.dynxsty.dih4jda.commands.interactions.context_command.UserContextInteraction in project DIH4JDA by DynxstyGIT.
the class InteractionHandler method getContextCommandData.
/**
* Gets the complete {@link CommandData} from a single {@link BaseContextCommand}.
*
* @param command The base context command's instance.
* @param commandClass The base context command's class.
* @return The new {@link CommandListUpdateAction}.
*/
private CommandData getContextCommandData(@NotNull BaseContextCommand command, Class<? extends BaseContextCommand> commandClass) {
if (command.getCommandData() == null) {
DIH4JDALogger.warn(String.format("Class %s is missing CommandData. It will be ignored.", commandClass.getName()));
return null;
}
CommandData commandData = command.getCommandData();
if (commandData.getType() == Command.Type.MESSAGE) {
messageContextIndex.put(commandData.getName(), new MessageContextInteraction((IMessageContextCommand) command));
} else if (commandData.getType() == Command.Type.USER) {
userContextIndex.put(commandData.getName(), new UserContextInteraction((IUserContextCommand) command));
} else {
DIH4JDALogger.error(String.format("Invalid Command Type \"%s\" for Context Command! This command will be ignored.", commandData.getType()));
return null;
}
DIH4JDALogger.info(String.format("\t[*] Registered context command: %s", command.getCommandData().getName()), DIH4JDALogger.Type.CONTEXT_COMMAND_REGISTERED);
return commandData;
}
Aggregations