✏️Custom actions

As said before, custom actions are similar to validators, but they don't act as middlewares and generally they run after the action has been triggered.

An example of custom actions can be found in the "Anti crasher" plugin.

In this case, the custom actions will trigger when an error occurs.

In this example, we will send a message into a channel in case of an error. We will also create a command that triggers the error.

Creating the command

In this part I am assuming that you already read the guide on how to create a custom command. If you didn't, here is the link.

If you don't care about the command, go into the next section

I created a new playground and made a basic command

Now, open the "Other" category and drag the "Throw" block into the statement

Add the "Word" block and put whatever you want.

Defining actions

After creating the command, you can enter the workspace of the custom actions in the Anti crasher plugin.

After entering the workspace, you will find something like this

You probably noted that the Anti crasher plugin added some blocks: we won't need them.

Now, since we are only trying to send a message into a channel, we will only need few blocks.

Step 1

Grab the "Send in channel..." block and drag it under the "On action trigger" event.

Step 2

In the same category, grab the "Find channel with..." block and drag it in the right field

Now, since the "Anti crasher" plugin uses a node's function and the error may not be discord-related, we are not able to determine the server, or at least, determine it easly. This means that we will specify our own server.

In the "Server" category grab the "Find server with name.." block

Grab the "Word" block and put it in the right field

Step 3

Lastly, customise the channel name and the message

Remember to save!

Demo

Triggering the error

We are not getting any reply because we did not set up a response, but it's okay, because it triggered the error

Last updated

Was this helpful?