Create Discord bots using a simple widget-based framework.
- Go to Discord's Developer Portal.
- Create a new application.
- Add a bot user to your app.
- Find your bot token, you will need this in the next section.
Keep this token and any file containing it private! If your token ever leaks or you suspect it may have leaked, simply
regenerate
a new token to invalidate your compromised token.
- Invite your bot to a server using: https://discordapp.com/oauth2/authorize?scope=bot&client_id=COPY_PASTE_YOUR_DISCORD_BOT_CLIENT_ID_HERE
A Discord bot's client ID is not the same as its token!
git clone https://github.com/peterthehan/create-discord-bot.git
to download the project.cd create-discord-bot/
to navigate into the project.npm install
to install project dependencies.- Rename example.token.json to
token.json
. - Open the file and add the bot token found in the previous section:
{
"TOKEN": "COPY_PASTE_YOUR_DISCORD_BOT_TOKEN_HERE"
}
npm start
to start the bot.
The bot should go from offline to online. Verify the bot is working by using the ping command.
The default command prefix is
.
. You can configure the command widget's settings in src/widgets/command/config.js.
🎉 You're ready to create your own widgets! 🎉
create-discord-bot
comes with a command widget. Simply follow the design of the ping command to start building your own commands.
Each widget must live under the src/widgets folder and must have a handlers
folder containing only event handler files. In other words, a file tree diagram of these requirements would look like:
widgets
├───widget1
│ ├───handlers
| | ├───eventHandler1.js*
| | ├───eventHandler2.js
| | └───other event handlers
├───widget2
│ ├───handlers
| | ├───eventHandler1.js
| | ├───eventHandler2.js
| | └───other event handlers
*: All event handler files must be named exactly the same as the emitted events found on the Client page.
The following widgets can be used by this framework by moving 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-emoji-log-bot
- https://github.com/peterthehan/discord-reaction-role-bot
Visit for more help or information!