1313import net .dv8tion .jda .api .requests .RestAction ;
1414import net .dv8tion .jda .api .requests .restaction .AuditableRestAction ;
1515import net .dv8tion .jda .api .utils .Result ;
16+ import net .dv8tion .jda .api .utils .TimeUtil ;
1617import net .dv8tion .jda .internal .requests .CompletedRestAction ;
1718import org .slf4j .Logger ;
1819import org .slf4j .LoggerFactory ;
@@ -53,9 +54,9 @@ private ModerationUtils() {
5354 */
5455 private static final int REASON_MAX_LENGTH = 512 ;
5556 /**
56- * The maximum amount of moderation actions displayed on a single page
57+ * The maximum amount of moderation actions displayed on a single audit log page
5758 */
58- private static final int MAX_PAGE_LENGTH = 10 ;
59+ private static final int MAX_AUDIT_PAGE_LENGTH = 10 ;
5960 /**
6061 * Human-readable text representing the duration of a permanent action, will be shown to the
6162 * user as option for selection.
@@ -457,42 +458,44 @@ record TemporaryData(Instant expiresAt, String duration) {
457458 /**
458459 * Splits a list of moderation records into discrete pages capped at 10 items each.
459460 *
460- * @param actions the list of chronological actions against a target
461+ * @param moderationActions the list of chronological actions against a target
461462 * @return a list of sub-lists where each sub-list contains a maximum of 10 items
462463 */
463- public static List <List <ActionRecord >> groupActionsByPages (List <ActionRecord > actions ) {
464- List <List <ActionRecord >> groupedActions = new ArrayList <>();
464+ public static List <List <ActionRecord >> groupActionsByPages (
465+ List <ActionRecord > moderationActions ) {
466+ List <List <ActionRecord >> groupedModerationActions = new ArrayList <>();
465467
466- for (int i = 0 ; i < actions .size (); i ++) {
467- if (i % MAX_PAGE_LENGTH == 0 ) {
468- groupedActions .add (new ArrayList <>(MAX_PAGE_LENGTH ));
468+ for (int i = 0 ; i < moderationActions .size (); i ++) {
469+ if (i % MAX_AUDIT_PAGE_LENGTH == 0 ) {
470+ groupedModerationActions .add (new ArrayList <>(MAX_AUDIT_PAGE_LENGTH ));
469471 }
470- groupedActions .getLast ().add (actions .get (i ));
472+ groupedModerationActions .getLast ().add (moderationActions .get (i ));
471473 }
472474
473- return groupedActions ;
475+ return groupedModerationActions ;
474476 }
475477
476478 /**
477479 * Generates a structural text overview outlining the count total of each action type.
478480 *
479- * @param actions a collection of history records
481+ * @param moderationActions a collection of history records
480482 * @return a formatted markdown description summary
481483 */
482- public static String createSummaryMessageDescription (Collection <ActionRecord > actions ) {
483- int actionAmount = actions .size ();
484+ public static String createSummaryMessageDescription (
485+ Collection <ActionRecord > moderationActions ) {
486+ int moderationActionAmount = moderationActions .size ();
484487
485488 String shortSummary = "There are **%s actions** against the user."
486- .formatted (actionAmount == 0 ? "no" : actionAmount );
489+ .formatted (moderationActionAmount == 0 ? "no" : moderationActionAmount );
487490
488- if (actionAmount == 0 ) {
491+ if (moderationActionAmount == 0 ) {
489492 return shortSummary ;
490493 }
491494
492- Map <ModerationAction , Long > actionTypeToCount = actions .stream ()
495+ Map <ModerationAction , Long > moderationActionTypeToCount = moderationActions .stream ()
493496 .collect (Collectors .groupingBy (ActionRecord ::actionType , Collectors .counting ()));
494497
495- String typeCountSummary = actionTypeToCount .entrySet ()
498+ String typeCountSummary = moderationActionTypeToCount .entrySet ()
496499 .stream ()
497500 .filter (typeAndCount -> typeAndCount .getValue () > 0 )
498501 .sorted (Map .Entry .<ModerationAction , Long >comparingByValue ().reversed ())
@@ -506,28 +509,27 @@ public static String createSummaryMessageDescription(Collection<ActionRecord> ac
506509 /**
507510 * Converts an action record item asynchronously into a formatted embed data field.
508511 *
509- * @param actionRecord the moderation action history record to convert
512+ * @param moderationActionRecord the moderation action history record to convert
510513 * @param jda the active JDA instance used to resolve the moderator's handle
511514 * @return a rest action that resolves to the embed field representing the moderation action
512515 */
513- public static RestAction <MessageEmbed .Field > actionToEmbedField ( ActionRecord actionRecord ,
514- JDA jda ) {
515- return jda .retrieveUserById (actionRecord .authorId ())
516+ public static RestAction <MessageEmbed .Field > moderationActionToEmbedField (
517+ ActionRecord moderationActionRecord , JDA jda ) {
518+ return jda .retrieveUserById (moderationActionRecord .authorId ())
516519 .map (author -> author == null ? "(unknown user)" : author .getName ())
517520 .map (authorText -> {
518- String expiresAtFormatted = actionRecord .actionExpiresAt () == null ? ""
519- : "\n Temporary action, expires at: "
520- + net .dv8tion .jda .api .utils .TimeUtil .getDateTimeString (
521- actionRecord .actionExpiresAt ().atOffset (ZoneOffset .UTC ));
521+ String expiresAtFormatted = moderationActionRecord .actionExpiresAt () == null ? ""
522+ : "\n Temporary action, expires at: " + TimeUtil .getDateTimeString (
523+ moderationActionRecord .actionExpiresAt ().atOffset (ZoneOffset .UTC ));
522524
523- String embedFieldName =
524- "%s by %s" .formatted (actionRecord .actionType ().name (), authorText );
525+ String embedFieldName = "%s by %s"
526+ .formatted (moderationActionRecord .actionType ().name (), authorText );
525527 String embedFieldDescription = """
526528 %s
527529 Issued at: %s%s
528- """ .formatted (actionRecord .reason (),
529- net . dv8tion . jda . api . utils . TimeUtil
530- . getDateTimeString ( actionRecord .issuedAt ().atOffset (ZoneOffset .UTC )),
530+ """ .formatted (moderationActionRecord .reason (),
531+ TimeUtil . getDateTimeString (
532+ moderationActionRecord .issuedAt ().atOffset (ZoneOffset .UTC )),
531533 expiresAtFormatted );
532534
533535 return new MessageEmbed .Field (embedFieldName , embedFieldDescription , false );
0 commit comments