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);
}
});
}
Aggregations