Create an app and get your credentials
本頁內容尚未翻譯。
Status
Stable· Last verified 2026-07-11 · APIv10· Source Developer Portal
A concrete walkthrough to get every credential the examples need.
1. Create the application
Section titled “1. Create the application”- Go to the Developer Portal → Applications.
- Click New Application, name it, accept the terms, Create.
- On General Information, copy:
- Application ID →
DISCORD_APPLICATION_ID - Public Key →
DISCORD_PUBLIC_KEY(used to verify interactions)
- Application ID →
That’s enough for an interaction-endpoint app — no bot required.
2. (Optional) Add a bot user
Section titled “2. (Optional) Add a bot user”Only if you need to connect to the gateway or act as a bot member.
- Open the Bot tab.
- Click Reset Token → Copy → store as
DISCORD_BOT_TOKEN.- The token is shown once. If you lose it, reset again (which invalidates the old one).
- Configure Privileged Gateway Intents only if your app needs them
(
MESSAGE CONTENT,SERVER MEMBERS,PRESENCE) — see intents. Leave them off otherwise.
3. (Optional) OAuth2 credentials
Section titled “3. (Optional) OAuth2 credentials”For OAuth2 flows (login-with-Discord, installs):
- OAuth2 tab → copy Client ID (= Application ID).
- Reset Secret → store as
DISCORD_CLIENT_SECRET. - Add your Redirect URI(s) for the authorization-code flow.
4. Configure installation
Section titled “4. Configure installation”Under Installation (and Bot/OAuth2 as needed), choose the installation contexts your app supports:
- Guild Install — added to a server; can include the
botscope. - User Install — installed to a user; commands follow them across Discord.
Currently limited to the
applications.commandsscope by default.
Set the default install link so people can add your app.
5. Put it all in .env
Section titled “5. Put it all in .env”DISCORD_APPLICATION_ID=123456789012345678DISCORD_PUBLIC_KEY=abc... # not secret, but keep it tidyDISCORD_BOT_TOKEN=REPLACE_ME # SECRETDISCORD_CLIENT_SECRET=REPLACE_ME # SECRETCopy from the repo’s .env.example,
which documents every value. .env is git-ignored.
Verify the bot token
Section titled “Verify the bot token”curl "https://discord.com/api/v10/users/@me" \ -H "Authorization: Bot $DISCORD_BOT_TOKEN"A JSON user object with "bot": true means the token works.
- Register and handle commands → Interactions.
- Connect for live events → Gateway.
- Generate an install link with the right scopes → OAuth2.