huruhuru - v0.0.1
    Preparing search index...

    Function paginateMap

    • Map arbitrary items into SectionBuilder instances and call paginate.

      The mapper must have the signature (item: T, builder: SectionBuilder) => SectionBuilder. A fresh SectionBuilder instance is provided as the second argument to the mapper for each item; the mapper should populate and return that builder (or return a new SectionBuilder).

      Type Parameters

      • T

        item type to map

      Parameters

      • ctx: CommandContext

        CommandContext

      • items: T[]

        original items to map

      • mapper: (item: T, builder: SectionBuilder) => SectionBuilder

        mapping function (item, builder) => SectionBuilder. A fresh SectionBuilder is passed as builder for each call.

      • OptionaltopSection: T

        optional top section value (will be converted by calling mapper(topSection, new SectionBuilder()))

      • currentPage: number = 1

        initial page (default: 1)

      • pageSize: number = 10

        items per page (default: 10)

      • Optionalheader: string

        optional header text

      Returns Promise<MessagePagination>

      A MessagePagination instance

      // mapper that fills the provided builder per item
      await paginateMap(
      ctx,
      users,
      (user, builder) => builder.addTextDisplayComponents(t => t.setContent(user.name)),
      null,
      1,
      10,
      "Users",
      );