How to create a Discord bot, get its token and invite it
Make a bot in the Discord Developer Portal, copy its token safely, turn on the right intents and invite it to your server before hosting it on ESN.
Every Discord bot needs an application in the Discord Developer Portal. This guide covers the Discord side. When you're done, host the bot with the Python or Node.js guide.
1. Create the application #
- Go to discord.com/developers/applications and sign in with your Discord account.
- Choose New Application, give it a name and accept the terms.
- Open the Bot page on the left. Here you can set the bot's name and picture.
2. Copy the token #
- On the Bot page, choose Reset Token and confirm. Discord shows the token once.
- Copy it straight into a
.envfile in your server's top folder, for exampleDISCORD_TOKEN=your-token-here. Don't paste it in a chat, a screenshot or a public code repository.
.env and restart the server.3. Turn on intents (only the ones you need) #
Still on the Bot page, under Privileged Gateway Intents:
- Message Content: if your bot reads what people type (prefix commands like
!help). Slash commands don't need it. - Server Members: if your bot welcomes members, gives roles on join or reads the member list.
- Presence: only if your bot needs online/offline status.
Your code must ask for the same intents. If the code asks for one that's switched off here, Discord refuses to connect. See Troubleshooting.
4. Invite the bot to your server #
- Open OAuth2 and then URL Generator.
- Under scopes, tick bot and applications.commands (needed for slash commands).
- Tick the permissions your bot needs. Avoid Administrator unless you really need it.
- Copy the URL at the bottom, open it, pick your server and choose Authorize. You need the Manage Server permission on that server.
5. Host it on ESN #
The bot shows as offline until its code is running. Upload your code to an ESN server and start it, and it stays online 24/7:
Bot hosting starts at $0.50/month, and you can try it free first.
Still stuck? Use the live chat on the panel or ask in the ESN Hosting Discord. Last updated October 27, 2026.