🏁Creating a custom event

In this example, we will make the bot send a message in a public channel whenever a user joins the server. Please consider that in this example we are not going to consider that the bot is in multiple servers since that it will just overcomplicate this tutorial.

Step 1

In your bot dashboard, find "Custom events" and click it.

Step 2

Create a new playground and give it a name. You can change the name anytime you want.

Step 3

After you created the playground, click on the "Enter" button to modify it.

Step 4

After entering the playground, you will find something like this.

Note how there is an entire section in the toolbox dedicated to events

Step 5

Since we are trying to make the bot greet someone, we will need a block that will run actions whenever the user joins.

This block can be found in Server > Member join

Step 6

Now, drag and drop the block into the workspace

Step 7

Now the greeting part, we will need to send a message into a channel.

Since sending messages isn't an event-related thing, we can find the block we need in the Channels category

Like the other one, we can drag this block under a parent block, in this case the one added before

Like this

Step 8

We are not done yet, since we still need to specify the channel where we want to send the message and the actual message!

For the channel, we can find the right block in the same Channels category.

And make sure it snaps correctly in the last block we added

Now let's specify the channel name! For example, if I want to send my greeting message into a channel called "arrivals", I will do this:

Feel free to change it however you want.

In production, it is better to never reference anything with the name, since for example the channel name changes, or there are multiple channels with the same name, it can give problems. The ID property instead is unique and will never change

However, if you are a newbie, the "name" property should be fine since it's much easier to work with

It's now time to specify the server. Since this tutorial does not consider the fact that the bot might be in multiple servers, we will use the block "get server by name"

And drag it like this

Click on "id" and select "name"

To specify the name we will need a string, that block can be found in the "Text" category

Drag it inside the right field and put your server name

We are almost done! Now we only need to specify the message

In the same Text section as the block before, let's grab the "create text with" block

And drag it in the right spot

Now we will need another field. Click on the little blue gear icon and drag the "item" block under the other ones

Now, to ping a user we will actually need the user id. You probably know that to mention a user, discord under the hood instead of sending @user it sends <@userID>. For example, if I want to mention @burrito2, discord will instead send <@38950472305>, since that number is the id of burrito2

As you can see I already used the "Word" block in the first field and set it's value to "Welcome <@"

You can probably guess that in the field in the middle there will be the user id and in the last field will be ">".

Go into the User category and drag the block "ID of user"

We now need the Event user object. You probably spotted it before, but since it's an event-related thing, We can find it in the "Events" section.

What is the event user object?

The "Event user object" is a block that contains all the data about the user, such as ID, Username, Presence, Description etc.

To get the actually needed data, we use another block that "extracts" what we need from the object

This concept applied to every aspect of the builder and it's valid for Channels, Servers, Users etc.

This is a very simple way of explaining it since the whole concept of "object" in JavaScript is more complex, but it's all what you need to know for this builder.

Lastly, as said before, we add another "Word" block

Step 9

Now that we are done, hit save and test your bot!

Congrats!

Here it is!

Last updated

Was this helpful?