Goal: Understand the “magic” without editing utils.
Up until now, you’ve been creating commands like ping.js and they just work.
But what’s actually happening behind the scenes?
This lesson explains how your bot receives commands, finds the correct file, and executes it.
Start with a command you already made, like:
commands/ping.js
This file contains an execute() function that runs when the command is used.
Go to your events/ folder and open the interaction file.
This is where all Discord interactions enter your bot.
You should see something like:
interactionCreate
→ identify interaction type
→ look up command/component
→ run checks (cooldowns/permissions)
→ execute()
Here’s what each step means:
execute() function.“When a user runs a slash command, the bot receives an interaction event, finds the matching command file, and executes its function.”
Think of the system like a receptionist:
The receptionist receives the request and sends it to the right person.