0

呼び出されると、チームのリスト (リストに保存されている) をチェックボックス付きで出力するスラッシュ コマンドがあります。チーム名が横にあるチェックボックスの作成に問題はありませんが、チーム名がハードコードされている場合のみです。リストを反復処理して、不明な量のチェックボックスを作成するにはどうすればよいですか?

app.command("/message", (req, ctx) -> {
  ctx.respond(res -> res
    .responseType("in_channel") // or "in_channnel"
    .blocks(asBlocks(
      section(section -> section.text(markdownText("Select channels to receive message")).accessory(
        checkboxes(checkboxes -> checkboxes
          .options(asOptions(
            option(option -> option.value("0").text(markdownText("some-team")))
            option(option -> option.value("1").text(markdownText("another-team")))
          ))
        )
      )),
      actions(actions -> actions
        .elements(asElements(
          button(b -> b.actionId("submit").text(plainText
            (pt -> pt.emoji(true).text("Submit"))).style("primary").value("submit"))
        ))
      )
    ))
  );
  return ctx.ack();
});
4

1 に答える 1