Components V2 (Discord ContainerBuilder)

Discord Components V2 architecture: ContainerBuilder, TextDisplayBuilder, SeparatorBuilder and 5 button styles.

Documentation / Resources / Scripting / Components V2

  1. 1. Define ContainerBuilder

    Create the main container with the accent color.

    const container = new ContainerBuilder().setAccentColor(0x0066ff);
  2. 2. Add Text and Separator

    Set up a modern card layout with TextDisplayBuilder and SeparatorBuilder.

    container.addTextDisplayComponents(new TextDisplayBuilder().setContent('# Title'));
  3. 3. Buttons and Selection Menu

    Attach a ButtonBuilder or StringSelectMenu inside ActionRowBuilder.

    interaction.reply({ components: [container], flags: MessageFlags.IsComponentsV2 });

Components V2, the newest UI standard of the Discord API, offers modern, fluid, and high-contrast card structures that replace old embeds. All Aegis bot interfaces are written with this architecture.

Components V2 Code Structure

Example Components V2 Cardjavascript
const container = new ContainerBuilder().setAccentColor(0x55ff55);
container.addTextDisplayComponents(
  new TextDisplayBuilder().setContent('# 🛡️ Anti-Nuke protection is on')
);
container.addSeparatorComponents(new SeparatorBuilder());
container.addTextDisplayComponents(
  new TextDisplayBuilder().setContent('All channels and roles are under strong protection.')
);
container.addActionRowComponents(
  new ActionRowBuilder().addComponents(
    new ButtonBuilder().setCustomId('btn_test').setLabel('Audit').setStyle(ButtonStyle.Success)
  )
);
await interaction.reply({ components: [container], flags: MessageFlags.IsComponentsV2 });

Providing MessageFlags.IsComponentsV2 to the flags parameter is mandatory.

5 Button Styles

Primary (1):
Main button with blue accent. Used for form submission or starting an action.
Secondary (2):
Gray neutral button. Suitable for settings, details, or panels.
Success (3):
Green confirm button. Used for verification, accepting, or enabling protection.
Danger (4):
Red danger button. Ban, panic mode, or server lock actions.
Link (5):
Gray external link button. Redirects to the web panel or documentation.