Create Discord bots using a simple widget-based framework.
-
Go to Discord's Developer Portal.
-
Create a new application.
-
Go to the bot tab and add a bot user to your application.
Take note of the bot token on this page—you will need it in the next section.
Keep your token and any file containing it private. If it ever leaks or you suspect it may have leaked, simply
regenerate
a new token to invalidate your compromised token. -
In the bot tab, scroll down to the
Privileged Gateway Intents
section and enable the toggles for bothPresence Intent
andServer Members Intent
. More details onGateway Intents
can be found here:
npx peterthehan/create-discord-bot
Follow the instructions given by the utility. Once the bot is running, verify the setup is working by sending the .ping
command on Discord. If there are issues, check Troubleshooting for tips.
You're ready to create your own Discord bot! 🎉
Update your core bot files to the latest version in this project by running npx peterthehan/create-discord-bot
and entering the same name as your existing Discord bot when asked for the application name. This will update:
create-discord-bot
includes a command widget. Follow the design of the ping command to start building your own commands.
- All widgets must live under the src/widgets/ folder.
- All widgets must have a
handlers
folder. - A
handlers
folder can only contain event handler files. - All event handler files must be named exactly the same as the events found on the Client page.
An example file tree diagram of these requirements may look like:
src/
widgets/
command/
handlers/
ready.js
message.js
widget1/
handlers/
messageReactionAdd.js
messageUpdate.js
other event handlers
widget2/
handlers/
typingStart.js
userUpdate.js
other event handlers
The following widgets can be used by this framework by adding them into the src/widgets/ folder:
- https://github.com/peterthehan/discord-active-role-bot
- https://github.com/peterthehan/discord-audit-log-bot
- https://github.com/peterthehan/discord-birthday-role-bot
- https://github.com/peterthehan/discord-cron-bot
- https://github.com/peterthehan/discord-emoji-log-bot
- https://github.com/peterthehan/discord-reaction-role-bot
- https://github.com/peterthehan/discord-starboard-bot
- https://github.com/peterthehan/discord-superactive-role-bot
- https://github.com/peterthehan/discord-twitter-bot
- Remove bots 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.
npm -v
to check if your npm version supports npx (v5.2+).node -v
to check if you have the latest LTS version of Node.js (v12+).npm install
if running the application outputsError: Cannot find module '...'
.
Visit for more help or information!
Read the Contributing documentation to get started!