Search in sources :

Example 1 with BotCommandMappingHandler

use of com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandMappingHandler in project lavaplayer by sedmelluq.

the class BotApplicationManager method onMessageReceived.

@Override
public void onMessageReceived(final MessageReceivedEvent event) {
    Member member = event.getMember();
    if (!event.isFromType(ChannelType.TEXT) || member == null || member.getUser().isBot()) {
        return;
    }
    BotGuildContext guildContext = getContext(event.getGuild());
    controllerManager.dispatchMessage(guildContext.controllers, "!/", event.getMessage(), new BotCommandMappingHandler() {

        @Override
        public void commandNotFound(Message message, String name) {
        }

        @Override
        public void commandWrongParameterCount(Message message, String name, String usage, int given, int required) {
            event.getTextChannel().sendMessage("Wrong argument count for command").queue();
        }

        @Override
        public void commandWrongParameterType(Message message, String name, String usage, int index, String value, Class<?> expectedType) {
            event.getTextChannel().sendMessage("Wrong argument type for command").queue();
            ;
        }

        @Override
        public void commandRestricted(Message message, String name) {
            event.getTextChannel().sendMessage("Command not permitted").queue();
            ;
        }

        @Override
        public void commandException(Message message, String name, Throwable throwable) {
            event.getTextChannel().sendMessage("Command threw an exception").queue();
            ;
            log.error("Command with content {} threw an exception.", message.getContentDisplay(), throwable);
        }
    });
}
Also used : BotCommandMappingHandler(com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandMappingHandler) Message(net.dv8tion.jda.api.entities.Message) Member(net.dv8tion.jda.api.entities.Member)

Aggregations

BotCommandMappingHandler (com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandMappingHandler)1 Member (net.dv8tion.jda.api.entities.Member)1 Message (net.dv8tion.jda.api.entities.Message)1