Skip to main content
A minimal Discord bot in Python with discord.py 2.7.1 and a /ping command. This is a code template: the code is yours, open and editable, and Vertra Cloud runs what is in src/.

What it creates

One app (code) on the Python runtime, with no web address: the bot only makes outgoing connections. It needs at least 100 MB of memory (256 MB recommended) and no image slot, so any plan can run it. See What are templates.
  • It logs in with the bot token, registers the /ping slash command on every start and answers with the gateway latency.
  • It uses only the Guilds intent, so there is no privileged intent to turn on.
  • With no token or a wrong token the process exits with code 1 and a clear message in the app log.
  • Source in src/main.py; dependencies in src/requirements.txt.

What the wizard asks

First steps

1

Create the bot and get the token

In the Discord Developer Portal create a New Application, open Bot and click Reset Token. Copy the value: it is shown only once.
2

Paste it in the wizard

Paste the token when the wizard asks. It is stored encrypted and never goes in the code.
3

Invite the bot

In OAuth2 > URL Generator tick the scopes bot and applications.commands, open the generated URL and choose your server.
4

Check

After the deploy the app log shows Logged in as <bot name>. In Discord, type /ping: the bot answers Pong! with the latency. The global command can take a few minutes to appear the first time.

Make it your own

Open src/main.py, add your commands and deploy again, or restart if you edited in the app’s editor. To add libraries, list them in requirements.txt with a pinned version: the platform installs dependencies on every deploy. Editing the code detaches the app from the template, so it stops receiving new versions of it. See Update and roll back.

Reference

Limits and common problems

  • Two copies with the same token would answer twice, so zero-downtime deploy is off.
  • The minimum is 100 MB, and 256 MB (the recommended size) is enough for a simple bot. A bot on many servers or with a large cache needs more; you can raise the memory.
  • Discord global commands are slow to propagate. For tests, register guild commands in your code.
  • Login failed in the log. DISCORD_TOKEN is not the bot token. Reset it in the Portal, update the variable and restart.
  • /ping does not show up. Wait a few minutes and check that the invite had the applications.commands scope.
  • The app does not stay up. Without a valid token the process exits with code 1. Fix the token and restart.

License

The template’s code is by Vertra Cloud, under the MIT license. discord.py is distributed under the MIT license. See also the other official templates and the tutorial Create a Discord bot template.
Last modified on October 28, 2026