Building components
Having sent the component within a channel it’s about time you want to handle the interaction from the component.
To handle them we have to tell seyfert where will be the components located in our project. We have to do this within our seyfert config file.
First of all we are going to create a file inside the directory we have set for the components.
Then we are going to create a class which extends ComponentCommand
, something like we do with simple commands, and then we are going to set the type of the component we want to handle (Buttons
or anytype of SelectMenu
)
In this example I have created a component to reply Hello World
to the interaction. I have set the customId of the button to hello-world
.
Filtering component interactions
Now we want the handler to handle only the interactions created by the HelloWorld
button so we will use the customId we have to set in all the components.
To filter the interactions we are using a function inherited by the ComponentCommand
class in which we have to return a boolean.
Running the component handler
If the filter function success and returns true
the handler will execute a run
function with your code logic.