use of net.javadiscord.javabot.systems.moderation.warn.dao.WarnRepository in project JavaBot by Java-Discord.
the class WarnsCommand method handleSlashCommandInteraction.
@Override
public ReplyCallbackAction handleSlashCommandInteraction(SlashCommandInteractionEvent event) throws ResponseException {
OptionMapping warnsOption = event.getOption("user");
Member member = warnsOption == null ? event.getMember() : warnsOption.getAsMember();
if (member == null)
return Responses.error(event, "Member is missing.");
LocalDateTime cutoff = LocalDateTime.now().minusDays(Bot.config.get(event.getGuild()).getModeration().getWarnTimeoutDays());
try (var con = Bot.dataSource.getConnection()) {
return event.replyEmbeds(buildWarnsEmbed(new WarnRepository(con).getWarnsByUserId(member.getIdLong(), cutoff), member));
} catch (SQLException e) {
throw ResponseException.error("Could not get warns from user: " + member.getUser().getAsTag(), e);
}
}
use of net.javadiscord.javabot.systems.moderation.warn.dao.WarnRepository in project JavaBot by Java-Discord.
the class WarnsCommand method handleUserContextCommandInteraction.
@Override
public ReplyCallbackAction handleUserContextCommandInteraction(UserContextInteractionEvent event) throws ResponseException {
LocalDateTime cutoff = LocalDateTime.now().minusDays(Bot.config.get(event.getGuild()).getModeration().getWarnTimeoutDays());
Member member = event.getTargetMember();
try (var con = Bot.dataSource.getConnection()) {
return event.replyEmbeds(buildWarnsEmbed(new WarnRepository(con).getWarnsByUserId(member.getIdLong(), cutoff), member));
} catch (SQLException e) {
throw ResponseException.error("Could not get warns from user: " + member.getUser().getAsTag(), e);
}
}
Aggregations