Skip to main content

Events

An event block runs its contents when something happens in Discord. Everything a bot does automatically, without anyone typing a command, starts with one of these.

The subcategories​

PageFires when
Server ActionsA member joins or leaves, or the bot is added to or removed from a server
BoostsSomebody boosts, unboosts, or the server's boost level changes
Message ActionsA message is deleted, edited, pinned, replied to, or reacted to
Member ActionsA role is given or taken, or a nickname changes
Voice ActionsA member joins or leaves a voice channel
Thread ActionsA thread is created or deleted
Emojis and StickersAn emoji or sticker is created, deleted or changed
CustomAny discord.js event that does not have a block of its own

Events in other categories​

Not every event lives here. The ones tied to a specific feature sit with that feature:

EventWhere
When the bot is logged inMain
When a message is receivedMessage
When a slash command is receivedSlash
When a context menu is clickedContext Menus
When a modal is submittedModals
When a button is clickedButtons
When a menu is clickedSelect Menus
When a vote is added to a pollPolls
When an invite is created or deletedInvites

How event blocks work​

Each event comes with companion blocks that describe what happened. when a member joins a server is paired with member that joined, server the member joined to and invite the member joined with.

Those companion blocks only work inside their own event. Dragging member that joined into a slash command handler will not do anything useful, because nothing joined.

Intents​

Discord will not send your bot some events unless the matching intent is switched on in the Discord Developer Portal:

IntentNeeded for
Server MembersJoins, leaves, role changes, nickname changes, member loops
PresenceMember online status and activities
Server Voice StatesVoice channel joins and leaves
Message ContentThe text of messages the bot was not mentioned in

If an event never fires and the blocks look right, an intent is the first thing to check. See Creating a Discord bot.

Duplicate events​

You can have several copies of the same event block, in the same workspace or across different workspaces. All of them run. This is a good way to keep unrelated features apart: one when a member joins for the welcome message, another for the autorole.