/** * Invokes the method of the command. * * @param command The command. * @param message The original message. * @param parameters The parameters for the method. */ private void invokeMethod(SimpleCommand command, Message message, Object[] parameters) { Method method = command.getMethod(); Object reply = null; try { method.setAccessible(true); reply = method.invoke(command.getExecutor(), parameters); } catch (Exception e) { logger.warn("An error occurred while invoking method {}!", method.getName(), e); } if (reply != null) { message.getChannel().sendMessage(String.valueOf(reply)); } }
/** * Invokes the method of the command. * * @param command The command. * @param event The event. * @param parameters The parameters for the method. */ private void invokeMethod(SimpleCommand command, MessageReceivedEvent event, Object[] parameters) { Method method = command.getMethod(); Object reply = null; try { method.setAccessible(true); reply = method.invoke(command.getExecutor(), parameters); } catch (IllegalAccessException | InvocationTargetException e) { logger.warn("An error occurred while invoking method {}!", method.getName(), e); } if (reply != null) { event.getChannel().sendMessage(String.valueOf(reply)).queue(); } }
/** * Invokes the method of the command. * * @param command The command. * @param event The event. * @param parameters The parameters for the method. */ private void invokeMethod(SimpleCommand command, MessageReceivedEvent event, Object[] parameters) { Method method = command.getMethod(); Object reply = null; try { method.setAccessible(true); reply = method.invoke(command.getExecutor(), parameters); } catch (IllegalAccessException | InvocationTargetException e) { Discord4J.LOGGER.warn("Cannot invoke method {}!", method.getName(), e); } if (reply != null) { try { event.getMessage().getChannel().sendMessage(String.valueOf(reply)); } catch (MissingPermissionsException | RateLimitException | DiscordException ignored) { } } }
Message message = event.getMessage(); String[] args = Arrays.copyOfRange(splitMessage, 1, splitMessage.length); Class<?>[] parameterTypes = command.getMethod().getParameterTypes(); final Object[] parameters = new Object[parameterTypes.length]; int stringCounter = 0;
Class<?>[] parameterTypes = command.getMethod().getParameterTypes(); final Object[] parameters = new Object[parameterTypes.length]; int stringCounter = 0;
Class<?>[] parameterTypes = command.getMethod().getParameterTypes(); final Object[] parameters = new Object[parameterTypes.length]; int stringCounter = 0;