Discord bot with slash commands
A Node.js Discord bot with slash commands, ready to host on a small always-on server.
Create a Discord bot in Node.js using discord.js. - Slash commands: /ping, /help, and [MY COMMAND] with options. - A separate script to register commands for one test guild first. - Token and IDs from env vars; .env in .gitignore. - Graceful error replies (ephemeral) instead of crashes. - Instructions: create the app in the Discord Developer Portal, the minimum intents and permissions, the invite URL, and how to run it on a host that keeps processes alive.
Tips
- Serverless hosts that sleep aren't a fit for a gateway bot. Use an always-on process.
Works with: Cursor, Claude Code, Codex, Replit. Last reviewed 2026-11-13.