This sample Discord bot written in TypeScript is a great starting place for creating the bot of your β¨ dreams β¨.
Primarily using discord.js with examples used from the discord.js guide.
Features include (not limited to):
[!IMPORTANT] Most current or LTS version Node.js is required!
Clone the repository here on Github or from terminal (shown below)
git clone https://github.com/joeyk710/sample-discordjs-bot.git
cd sample-discordjs-bot
Rename .env.example to .env
Open the .env file and fill in the required values as shown below
DISCORD_TOKEN=
# Your bot token
GUILD_ID=
# Only put an ID here if you want commands to be registered in one server.
APPLICATION_ID=
# Your bot's application ID (can be found on Discord or on the Discord Developer Portal)
Installing dependencies
pnpm install
Deploying Commands
pnpm run deploy
[!NOTE] If there is no
GUILD_ID
in the .env file, commands will be registered globally.Only run this terminal script if you need to add commands or edit command data that do not appear in your server.
Starting the bot
pnpm run start
Name | Description |
---|---|
/ping | Responds with "Pong!" |
Echo | Echoes the message selected in the channel the command was sent in |
[!NOTE] Please check the discord.js docs, discord.js guide, and discord-api-types for proper types, properties and method usage.
You will notice the current discord.js guide uses
@discordjs/builders
for command creation. This template uses raw objects for creating commands which makes use of enum types ApplicationCommandType and ApplicationCommandOptionType.β οΈ This template assumes you have a general understanding of TypeScript β οΈ
If you have any problems, please don't hesitate to open an issue here.
Contributions are welcome! Please don't hesitate to open a pull request here.
This project is licensed under the GNU General Public License v3.0
- see the LICENSE.md file for details