Search in sources :

Example 1 with IMessageContextCommand

use of com.dynxsty.dih4jda.commands.interactions.context_command.IMessageContextCommand 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;
}
Also used : UserContextInteraction(com.dynxsty.dih4jda.commands.interactions.context_command.UserContextInteraction) CommandData(net.dv8tion.jda.api.interactions.commands.build.CommandData) SlashCommandData(net.dv8tion.jda.api.interactions.commands.build.SlashCommandData) MessageContextInteraction(com.dynxsty.dih4jda.commands.interactions.context_command.MessageContextInteraction) IMessageContextCommand(com.dynxsty.dih4jda.commands.interactions.context_command.IMessageContextCommand)

Aggregations

IMessageContextCommand (com.dynxsty.dih4jda.commands.interactions.context_command.IMessageContextCommand)1 MessageContextInteraction (com.dynxsty.dih4jda.commands.interactions.context_command.MessageContextInteraction)1 UserContextInteraction (com.dynxsty.dih4jda.commands.interactions.context_command.UserContextInteraction)1 CommandData (net.dv8tion.jda.api.interactions.commands.build.CommandData)1 SlashCommandData (net.dv8tion.jda.api.interactions.commands.build.SlashCommandData)1