---
title: "How to create a Discord bot with slash commands | StreetHosting"
description: "A simple guide to creating a Discord bot with slash commands: the minimum structure, good practices and how to publish it to production."
url: "https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands"
type: "page"
language: "en-US"
---

Discord Bots · 2 min · Beginner

Published on Jun 1, 2026 · Updated on Jun 1, 2026

# Create a Discord bot with slash commands

Slash commands improve the user experience and make your bot easier to use. Here is a clear path to get started.

By [Equipe StreetHosting](https://streethosting.com.br/en/autores#equipe-streethosting) · StreetHosting infrastructure and support team

[Getting started](https://streethosting.com.br/en/guides/topics/getting-started) [Automation and webhooks](https://streethosting.com.br/en/guides/topics/automation)

Summarize with:

[](https://chat.openai.com/?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "ChatGPT") [](https://claude.ai/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Claude") [](https://www.google.com/search?udm=50&aep=11&q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Google AI Mode") [](https://x.com/i/grok?text=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Grok") [](https://www.perplexity.ai/search/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Perplexity")

Share:

[](https://x.com/intent/tweet?text=How%20to%20create%20a%20Discord%20bot%20with%20slash%20commands&url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands "Share on X") [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands "Share on Facebook") [](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands "Share on LinkedIn") [](https://wa.me/?text=How%20to%20create%20a%20Discord%20bot%20with%20slash%20commands%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fdiscord-bots%2Fcreate-discord-bot-slash-commands "Share on WhatsApp")

For agents: Copy as Markdown [.md](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands.md)

[Previous Deploy a Discord bot with Node.js and PM2: env vars and auto restart](https://streethosting.com.br/en/guides/discord-bots/deploy-discord-bot-pm2)

In this guide 3 sections

* [Why use slash commands](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#por-que-usar-slash-commands)
* [Minimum structure](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#estrutura-minima)
* [Publishing](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#publicacao)

Quick answer

To create a Discord bot with **slash commands**, you need an application registered in the Discord developer portal, well-defined commands and a stable deploy routine.

## Why use slash commands[](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#por-que-usar-slash-commands)

Slash commands make the bot easier to use for people who are new to the server. Users type a slash and see ready-made suggestions, with descriptions and organized fields.

* A clearer experience for the community.
* Fewer typos.
* Commands that are easier to maintain over time.

## Minimum structure[](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#estrutura-minima)

1. Define commands that are genuinely useful for your audience.
2. Organize the code by commands and events.
3. Store the token in an environment variable.
4. Handle errors so the reply to the user does not break.

Start small, with a few well-built commands, and grow based on how the community actually uses the bot.

## Publishing[](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#publicacao)

After you validate it on a test server, publish it with a restart process and monitoring. For that, see the guide on [deploying with PM2](https://streethosting.com.br/en/guides/discord-bots/deploy-discord-bot-pm2).

If you want the bot online all the time, also check out [Discord bot hosting](https://streethosting.com.br/en/bots).

In this guide

* [Why use slash commands](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#por-que-usar-slash-commands)
* [Minimum structure](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#estrutura-minima)
* [Publishing](https://streethosting.com.br/en/guides/discord-bots/create-discord-bot-slash-commands#publicacao)

## Frequently asked questions

Are slash commands better than the old prefix commands?

In most cases yes, because they are more intuitive and cut down on typos.

Do I need a VPS to get started?

For testing you can use a local environment. For continuous use, 24/7 hosting is recommended.

Does a small bot need a lot of RAM?

Usually not. Early projects tend to run on a simple configuration.

Next step

See bot plans

24/7 Discord bots with fast activation and support in Portuguese.

[See bot plans](https://streethosting.com.br/en/bots)

[See Ryzen VPS Ryzen 9 9950X VPS in São Paulo with root access, NVMe and gamer Anti-DDoS.](https://streethosting.com.br/en/vps/ryzen)

## Related guides

[Discord bots Beginner 24/7 Discord bot hosting in Brazil Discord bot hosting 24/7 combines a process manager with automatic restart, a token kept out of your code, logs and a server in Brazil for low latency to the API and your players. 6 min Read guide](https://streethosting.com.br/en/guides/discord-bots/discord-bot-hosting-24-7) [Discord bots Intermediate Deploy a Discord bot with Node.js and PM2: env vars and auto restart PM2 is a popular Node process manager for Discord bots because it restarts after a crash, survives reboots when paired with the startup hook and centralizes basic logs without standing up a whole Kubernetes cluster. This guide covers the ecosystem file, env vars for the token and how it fits hosting in Brazil. 4 min Read guide](https://streethosting.com.br/en/guides/discord-bots/deploy-discord-bot-pm2)

[← Back to the Guide Center](https://streethosting.com.br/en/guides)
