Container

Represents a container component builder. Containers group other components together.

Signature

export declare class Container extends BaseComponentBuilder<APIContainerComponent>
JSDoc
Examples
const container = new Container()
 .addComponents(
     new TextDisplay('This is text inside a container!'),
     new ActionRow().addComponents(new Button().setLabel('Click me!'))
 )
 .setColor('Blue');

Properties

Methods

addComponents(...components: RestOrArray<ContainerBuilderComponents>): this;

Adds components to the container.

Parameters
components
The components to add. Can be a single component, an array of components, or multiple components as arguments.
Returns

The updated Container instance.

setComponents(...components: RestOrArray<ContainerBuilderComponents>): this;

Sets the components for the container, replacing any existing components.

Parameters
components
The components to set. Can be a single component, an array of components, or multiple components as arguments.
Returns

The updated Container instance.

setSpoiler(spoiler?: boolean): this;

Sets whether the container's content should be visually marked as a spoiler.

Parameters
spoiler
Whether the content is a spoiler (defaults to true).
Returns

The updated Container instance.

setColor(color: ColorResolvable): this;

Sets the accent color for the container.

Parameters
color
The color resolvable (e.g., hex code, color name, integer).
Returns

The updated Container instance.

setId(id: number): this;

Sets the ID for the container.

Parameters
id
The ID to set.
Returns

The updated Container instance.