addContainer method

void addContainer({
  1. required MessageBuilder builder,
  2. Color? color,
  3. bool? spoiler,
})

Adds a container with nested content.

Containers provide visual grouping with optional color theming and spoiler protection. The nested builder must not contain components that are top-level-only like AttachedFile or Section.

Example:

final nested = MessageBuilder()
  ..addText('This content is in a container')
  ..addText('With a blue background');

builder.addContainer(
  builder: nested,
  color: Color.blue,
  spoiler: false,
);

Implementation

void addContainer({
  required MessageBuilder builder,
  Color? color,
  bool? spoiler,
}) {
  _components.add(Container(color, spoiler, builder));
}