Lingo.Component.Layout (Lingo v0.4.2)

Copy Markdown View Source

Builders for components v2: text, images, files and containers laid out in the message itself. Messages using them need the Lingo.Component.v2_flag/0 flag and can't have :content or :embeds.

Lingo.Api.Message.create(channel_id, %{
  flags: Lingo.Component.v2_flag(),
  components: [
    Layout.container([Layout.text_display("**Server status**"), Layout.separator()],
      accent_color: 0x57F287
    )
  ]
})

Summary

Functions

A box around components, like an embed. Options: :accent_color and :spoiler.

An attached file, by attachment://name URL. Option: :spoiler.

One item of a media_gallery/1. Options: :description and :spoiler.

A grid of up to 10 images or videos, built with gallery_item/2.

Up to 3 text displays with an accessory (a button or a thumbnail) beside them.

Space between components. Options: :divider (draw a line) and :spacing (:small or :large).

Markdown text.

A small image, for a section's accessory. Options: :description and :spoiler.

A media reference by URL.

Functions

container(components, opts \\ [])

@spec container(
  [map()],
  keyword()
) :: map()

A box around components, like an embed. Options: :accent_color and :spoiler.

file(url, opts \\ [])

@spec file(
  String.t(),
  keyword()
) :: map()

An attached file, by attachment://name URL. Option: :spoiler.

media_gallery(items)

@spec media_gallery([map()]) :: map()

A grid of up to 10 images or videos, built with gallery_item/2.

section(text_displays, accessory)

@spec section([map()], map()) :: map()

Up to 3 text displays with an accessory (a button or a thumbnail) beside them.

separator(opts \\ [])

@spec separator(keyword()) :: map()

Space between components. Options: :divider (draw a line) and :spacing (:small or :large).

text_display(content)

@spec text_display(String.t()) :: map()

Markdown text.

thumbnail(url, opts \\ [])

@spec thumbnail(
  String.t(),
  keyword()
) :: map()

A small image, for a section's accessory. Options: :description and :spoiler.

unfurled_media(url)

@spec unfurled_media(String.t()) :: map()

A media reference by URL.