Skip to content

Building components

Components are built with a builder, which is a JavaScript class, which represents it. Within this builder you can customize the component such it’s text or it’s color.

There are diffrent types of components’ builders with diffrent customization but all have a common property: the custom Id. A unique identifier which is used for handling the interactions of the component.

ActionRow

All the builders are sent within an ActionRow. Each message can contain a maxium of 5 actions row.

Here is how we create a basic ActionRow:

1
import { ActionRow } from 'seyfert';
2
3
const row = new ActionRow()
4
5
.setComponents([])
6
7
.addComponents();

Building each component

Now we are going to build each type of component and set it within an ActionRow:

Buttons

An ActionRow shouldn’t contain more than 5 buttons.

1
import { ActionRow, Button } from 'seyfert';
2
import { ButtonStyle } from 'seyfert/lib/types';
3
4
const button = new Button()
5
.setCustomId('first-button')
6
.setStyle(ButtonStyle.Primary)
7
.setLabel('First Button');
8
9
const row = new ActionRow<Button>().setComponents([button]);

After creating the components you will have to send the ActionRow into the components field. See below.