Nostrum.Struct.Message.Component (Nostrum v0.5.0-rc2) View Source

A component attached to a message.

Note that the fields present depend on the type/0 of the component object.

See the Discord API Component Object Documentation for more information.

Link to this section Summary

Types

Child components for action rows.

A developer-defined identifier for the component.

Whether the component is disabled.

Partial emoji of the button.

Text that appears on the button.

Maximum number of items that must be chosen.

Minimum number of items that must be chosen.

Choices of the select menu.

Custom placeholder text if nothing is selected.

An integer representing the style of the button.

t()

Represents a message component.

Component type.

URL for link-style buttons.

Link to this section Types

Specs

components() :: [t()]

Child components for action rows.

Only present for action rows.

Specs

custom_id() :: String.t() | nil

A developer-defined identifier for the component.

Maximum of 100 characters. Only present for buttons and select menus.

Specs

disabled() :: boolean() | nil

Whether the component is disabled.

Only present for buttons and select menus.

Specs

emoji() :: Nostrum.Struct.Emoji.t() | nil

Partial emoji of the button.

Only present for buttons. The following fields are set:

  • name
  • id
  • animated

Specs

label() :: String.t() | nil

Text that appears on the button.

Maximum of 80 characters. Only present for buttons.

Specs

max_values() :: 1..25 | nil

Maximum number of items that must be chosen.

Defaults to 1. Maximum of 25. Only present for select menus.

Specs

min_values() :: 0..25 | nil

Minimum number of items that must be chosen.

Defaults to 1. Minimum of 0. Maximum of 25. Only present for select menus.

Specs

options() ::
  [
    %{
      :label => String.t(),
      :value => String.t(),
      optional(:description) => String.t(),
      optional(:emoji) => %{
        id: Nostrum.Struct.Emoji.id(),
        name: Nostrum.Struct.Emoji.name(),
        animated: Nostrum.Struct.Emoji.animated()
      },
      optional(:default) => boolean()
    }
  ]
  | nil

Choices of the select menu.

Maximum of 25 options. Only present for select menus.

References

See Discord Developer Portal: Select Option Structure.

Specs

placeholder() :: String.t() | nil

Custom placeholder text if nothing is selected.

Maximum of 100 characters. Only present for select menus.

Specs

style() :: 1 | 2 | 3 | 4 | 5 | nil

An integer representing the style of the button.

Only present for buttons.

Values

  • 1: Primary - blurple, custom_id required.
  • 2: Secondary - grey, custom_id required.
  • 3: Success - green, custom_id required.
  • 4: Danger - red, custom_id required.
  • 5: Link - grey, url required, navigates to the URL.

References

See Discord Developer Portal: Button Styles.

Specs

t() :: %Nostrum.Struct.Message.Component{
  components: components(),
  custom_id: custom_id(),
  disabled: disabled(),
  emoji: emoji(),
  label: label(),
  max_values: max_values(),
  min_values: min_values(),
  options: options(),
  placeholder: placeholder(),
  style: style(),
  type: type(),
  url: url()
}

Represents a message component.

Specs

type() :: 1 | 2 | 3

Component type.

This field is always set.

Values

  • 1: Action Row - A container for other components.
  • 2: Button - A button object.
  • 3: Select Menu - A select menu for picking from choices.

References

See Discord Developer Portal: Component Types.

Specs

url() :: String.t() | nil

URL for link-style buttons.

Only present for buttons.