create-discord-bot
create-discord-bot copied to clipboard
A module-based Discord bot template.
Create Discord Bot
A module-based Discord bot template.
Getting started
Register a Discord bot application
-
Go to Discord's Developer Portal.
-
Create a new application.
Take note of the
APPLICATION IDon the General Information tab page. You will need it to invite the bot to your server in step 5. -
Go to the Bot tab and add a bot user to your application.
Take note of the
TOKENon the Bot tab page. You will need it in step 3 of the next section.Keep your token and any file containing it private. If it ever leaks or you suspect it may have leaked, simply
regeneratea new token to invalidate your compromised token. -
While in the Bot tab, scroll down to the Privileged Gateway Intents section and enable the toggles for both
Presence IntentandServer Members Intent. More information on Gateway Intents can be found here: -
Lastly, invite the bot to your server using the following link template: https://discord.com/oauth2/authorize?scope=bot&client_id=APPLICATION_ID_HERE
Create a Discord bot project
-
Run the following commands to bootstrap a Discord bot project in your working directory:
Replace
my-discord-botin the commands below with your own preferred project name!npx degit peterthehan/create-discord-bot my-discord-botcd my-discord-botnpm i -
Run the following command to rename the existing
.env.examplefile to.env:mv .env.example .env -
Open the
.envfile and add your Discord bot token. -
Lastly, run the following command to start the bot:
npm startVerify the bot is running properly by sending messages in your server. The bot should log these messages in your terminal. If there are any issues, check Troubleshooting.
You're ready to create your own Discord bot! 🎉
If you were directed to follow the instructions found here from another README, return back there now and continue with the setup. Feel free to continue reading for more information.
Bots
The following bots can be used by this template by adding them into the /src/bots folder:
- discord-active-role-bot
- discord-audit-log-bot
- discord-birthday-role-bot
- discord-cron-bot
- discord-dad-bot
- discord-dynamic-voice-channels-bot
- discord-reaction-role-bot
- discord-starboard-bot
- discord-superactive-role-bot
- discord-twitter-bot
Troubleshooting
- Remove bots in your server that may conflict in functionality, e.g. multiple reaction role bots.
- Use Git Bash instead of the Command Prompt (cmd.exe) if you are on Windows.
- Check that your:
nodeversion is>=16.6.0by runningnode -v.npmversion is>=7.0.0by runningnpm -v.
- If running the application outputs:
Error: Cannot find module '...', try runningnpm iin the project directory.DiscordAPIError: Missing Permissions, verify your bot has the correctManagepermissions.
Visit for more help or information!
