use of com.freya02.botcommands.api.application.slash.GlobalSlashEvent in project BotCommands by freya022.
the class ApplicationCommandsBuilder method processSlashCommand.
private void processSlashCommand(ApplicationCommand applicationCommand, Method method) {
if (method.getAnnotation(JDASlashCommand.class).guildOnly()) {
if (!ReflectionUtils.hasFirstParameter(method, GlobalSlashEvent.class) && !ReflectionUtils.hasFirstParameter(method, GuildSlashEvent.class))
throw new IllegalArgumentException("Slash command at " + Utils.formatMethodShort(method) + " must have a GuildSlashEvent or GlobalSlashEvent as first parameter");
if (!ReflectionUtils.hasFirstParameter(method, GuildSlashEvent.class)) {
// If type is correct but guild specialization isn't used
LOGGER.warn("Guild-only slash command {} uses GlobalSlashEvent, consider using GuildSlashEvent to remove warnings related to guild stuff's nullability", Utils.formatMethodShort(method));
}
} else {
if (!ReflectionUtils.hasFirstParameter(method, GlobalSlashEvent.class))
throw new IllegalArgumentException("Slash command at " + Utils.formatMethodShort(method) + " must have a GlobalSlashEvent as first parameter");
}
final SlashCommandInfo info = new SlashCommandInfo(context, applicationCommand, method);
LOGGER.debug("Adding slash command path {} for method {}", info.getPath(), Utils.formatMethodShort(method));
context.addSlashCommand(info);
}
Aggregations