Discord bot (JavaScript)
Discord bot with discord.js and a /ping command. A starting point for your bot.
Vertra1.0.0
About
Discord bot (JavaScript)
A minimal Discord bot in JavaScript, with discord.js 14.27.0 and a /ping command. This is a code template: the code is yours, open and editable; Vertra runs what is in src/.
What it is
- It logs in with the bot token, registers the
/pingslash command on every start and answers with the gateway latency. - Only the
Guildsintent (no privileged intent to turn on in the Developer Portal). - With no token or a wrong token the process exits with code 1 and a clear message in the app log.
- Source in
src/index.js; dependencies insrc/package.json.
What the wizard asks
| Question | What it does |
|---|---|
| Bot token | Becomes the DISCORD_TOKEN variable (encrypted). See step 1 below to get it. |
What you get
- The app (no web address: the bot only makes outgoing connections).
- Next step: invite the bot to your server and use
/ping.
First steps
- In the Discord Developer Portal(discord.com), create an application, open Bot and use Reset Token; copy the token.
- Paste the token when the wizard asks for it.
- Invite the bot to your server: OAuth2 > URL Generator, scopes
botandapplications.commands. - Type
/ping. The global command can take a few minutes to show up the first time. - To change the bot, edit
src/index.js(in the app's editor/files or by deploy) and restart.
Known limits
- There is no web page: the healthcheck is only the ready-gate (the process has to stay up).
- Two copies with the same token would answer twice: zero-downtime deploy is off.
- The minimum is 100 MB, and 256 MB (the recommended size) is enough for a simple bot; bots on many servers or with a large cache need more (RAM can be raised).
- The token lives in an encrypted variable; never put it in the code.
- Discord global commands are slow to propagate; for tests use guild commands in your code.
License
This template's code is by Vertra Cloud, under the MIT license (see the repository LICENSE). discord.js 14.27.0 is distributed under the Apache-2.0 license: https://github.com/discordjs/discord.js/blob/main/LICENSE.
More details: docs/first-steps.en.md · docs/reference.en.md