@@ -52,6 +52,10 @@ private ModerationUtils() {
5252 * {@link AuditableRestAction#reason(String)}.
5353 */
5454 private static final int REASON_MAX_LENGTH = 512 ;
55+ /**
56+ * The maximum amount of moderation actions displayed on a single page
57+ */
58+ private static final int MAX_PAGE_LENGTH = 10 ;
5559 /**
5660 * Human-readable text representing the duration of a permanent action, will be shown to the
5761 * user as option for selection.
@@ -458,11 +462,10 @@ record TemporaryData(Instant expiresAt, String duration) {
458462 */
459463 public static List <List <ActionRecord >> groupActionsByPages (List <ActionRecord > actions ) {
460464 List <List <ActionRecord >> groupedActions = new ArrayList <>();
461- final int maxPageLength = 10 ;
462465
463466 for (int i = 0 ; i < actions .size (); i ++) {
464- if (i % maxPageLength == 0 ) {
465- groupedActions .add (new ArrayList <>(maxPageLength ));
467+ if (i % MAX_PAGE_LENGTH == 0 ) {
468+ groupedActions .add (new ArrayList <>(MAX_PAGE_LENGTH ));
466469 }
467470 groupedActions .getLast ().add (actions .get (i ));
468471 }
@@ -503,29 +506,31 @@ public static String createSummaryMessageDescription(Collection<ActionRecord> ac
503506 /**
504507 * Converts an action record item asynchronously into a formatted embed data field.
505508 *
506- * @param action the record data item
509+ * @param actionRecord the moderation action history record to convert
507510 * @param jda the active JDA instance used to resolve the moderator's handle
508- * @return a field representation task mapping out the execution card detail
511+ * @return a rest action that resolves to the embed field representing the moderation action
509512 */
510- public static RestAction <MessageEmbed .Field > actionToField (ActionRecord action , JDA jda ) {
511- return jda .retrieveUserById (action .authorId ())
513+ public static RestAction <MessageEmbed .Field > actionToEmbedField (ActionRecord actionRecord ,
514+ JDA jda ) {
515+ return jda .retrieveUserById (actionRecord .authorId ())
512516 .map (author -> author == null ? "(unknown user)" : author .getName ())
513517 .map (authorText -> {
514- String expiresAtFormatted = action .actionExpiresAt () == null ? ""
515- : "\n Temporary action, expires at: " + net .dv8tion .jda .api .utils .TimeUtil
516- .getDateTimeString (action .actionExpiresAt ().atOffset (ZoneOffset .UTC ));
517-
518- String fieldName = "%s by %s" .formatted (action .actionType ().name (), authorText );
519- String fieldDescription =
520- """
521- %s
522- Issued at: %s%s
523- """ .formatted (action .reason (),
524- net .dv8tion .jda .api .utils .TimeUtil
525- .getDateTimeString (action .issuedAt ().atOffset (ZoneOffset .UTC )),
526- expiresAtFormatted );
527-
528- return new MessageEmbed .Field (fieldName , fieldDescription , false );
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 ));
522+
523+ String embedFieldName =
524+ "%s by %s" .formatted (actionRecord .actionType ().name (), authorText );
525+ String embedFieldDescription = """
526+ %s
527+ Issued at: %s%s
528+ """ .formatted (actionRecord .reason (),
529+ net .dv8tion .jda .api .utils .TimeUtil
530+ .getDateTimeString (actionRecord .issuedAt ().atOffset (ZoneOffset .UTC )),
531+ expiresAtFormatted );
532+
533+ return new MessageEmbed .Field (embedFieldName , embedFieldDescription , false );
529534 });
530535 }
531536
0 commit comments