use of com.freya02.botcommands.api.parameters.UserContextParameterResolver in project BotCommands by freya022.
the class UserCommandInfo method execute.
public boolean execute(BContext context, UserContextInteractionEvent event, Consumer<Throwable> throwableConsumer) throws Exception {
final Object[] objects = new Object[commandParameters.size() + 1];
if (guildOnly) {
objects[0] = new GuildUserEvent(context, event);
} else {
objects[0] = new GlobalUserEvent(context, event);
}
for (int i = 0, commandParametersLength = commandParameters.size(); i < commandParametersLength; i++) {
ContextCommandParameter<UserContextParameterResolver> parameter = commandParameters.get(i);
if (parameter.isOption()) {
objects[i + 1] = parameter.getResolver().resolve(context, this, event);
// no need to check for unresolved parameters,
// it is impossible to have other arg types other than User (and custom resolvers)
} else {
objects[i + 1] = parameter.getCustomResolver().resolve(context, this, event);
}
}
applyCooldown(event);
getMethodRunner().invoke(objects, throwableConsumer);
return true;
}
Aggregations