Discord

How to make a Discord bot

Build a Discord bot with slash commands the modern way: the discord.js v14 basics, registering commands, hosting, and how to generate a working bot from a description with Devellix.

6 min read · Updated Jul 28, 2026

A Discord bot is a program that logs into Discord with a bot token and reacts to slash commands, buttons, and events in your server. Modern bots use slash commands (typed with a leading /) rather than reading raw message text, which is cleaner and what Discord now recommends.

The usual stack is Node.js with discord.js v14. This guide walks through what a bot needs, how commands get registered, and how to get a working, structured bot from a single sentence instead of assembling the boilerplate yourself.

Step by step

  1. 1

    Create the application and bot token

    In the Discord Developer Portal, create an application, add a bot, and copy its token. The token is a secret that lets your code log in as the bot, so it goes in an environment variable and is never committed to source control.

  2. 2

    Understand the shape of a discord.js bot

    A v14 bot creates a Client with the intents it needs, loads a set of command modules (each with a data definition and an execute function), and listens for interactionCreate to dispatch them. A separate deploy script registers the slash commands with Discord.

  3. 3

    Write your first slash command

    A command is a SlashCommandBuilder describing its name, description, and options, plus an execute function that replies to the interaction. Permission-gated actions, like a /ban, set the required member permissions so only the right roles can run them.

  4. 4

    Register commands and run the bot

    Run the deploy script once to register commands with your server, then start the bot process so it stays connected. Commands appear in the Discord command picker within seconds of registering.

  5. 5

    Generate the whole bot with Devellix

    Describe the bot on Devellix and pick Discord. It writes index.js, the command modules, a deploy-commands script, and package.json as a real discord.js v14 project, installs the dependencies, and bundles it. You add your token and run it.

  6. 6

    Host it so it stays online

    A bot has to run continuously to respond. Run it on a small VPS or a process manager, keep the token in the environment, and it stays connected. Because you own the code, you can host it anywhere Node runs.

What you can build

  • A moderation bot with /ban and /kick that logs to a channel
  • A ticket system with a button that opens a private channel
  • A leveling bot that grants XP for chatting with a /rank command
  • A reaction-role bot for self-assigned roles
  • A poll or giveaway bot with buttons
Describe yours

Frequently asked

Most modern bots use JavaScript or TypeScript with the discord.js library on Node.js. Devellix generates a discord.js v14 project with slash commands.
Yes. Slash commands are discoverable in Discord's command picker, validate their inputs, and do not require the message-content intent, so they are the recommended approach for new bots.
Yes. A bot must run continuously to respond, so it runs on a server or process manager rather than your laptop. You own the generated code, so you can deploy it anywhere Node runs.
With Devellix you describe the bot in plain English and it writes the full discord.js project. You still add your bot token and run it, and you can read or edit the generated source.

Keep reading

Stop reading. Start building.

Describe what you want and Devellix writes it, builds it, and hands you the source. Free credits to start.