Responders
Understand how the Responder class works
What are Responders?
The createResponder
function is powerful for handling different types of discord interactions. With it, we can respond to buttons, selection menus and modals, or all of them at the same time.
To create a Responder
you need to import the function and the enum from base
See a simple example below, let's send a button through a command and respond to it using the createResponder
function
This way we are responding to a fixed button component in a message where the customId is ping/button
, so any button that our bot sends that has this customId will be responded to by this function defined in the run
of our Responder
.
Responders
use the interactionCreate
event, which means that even if the bot restarts, if someone uses that button again, it will still be responded to with the defined function. The same applies to select menus and modals