This is a sample Discord bot written in TypeScript. It uses discord.js with examples used from the discord.js guide.
Features include:
- Command & event handler
- A sample slash command & context menu command
- Command cooldowns
- Command permission checks
- Guild-only option (commands can be used only in guilds)
- Clone the repository
- Open the .env file and fill in the required values shown below
TOKEN= # Your bot token
GUILD_ID= # Replace with your guild ID
# <- add infront of GUILD_ID if you want to register commands globally
CLIENT_ID= # Replace with your client id
- Rename the .env.example file to
.env
- Installing dependencies
npm install
- Deploying Commands
npm run deploy
If you want to deploy the commands to a single server, make sure you put a
GUILD_ID
in the .env file. Then runnpm run deploy
in your terminal.
If you want to deploy the commands to all servers, don't put a
GUILD_ID
in the .env file.
Note: Only run this command if you add commands or edit the command options such as the name
, description
, etc.
- Starting the bot
npm run start
Name | Description |
---|---|
/ping | Responds with "Pong!" |
Echo | Echoes the message selected in the channel the command was sent in |
Note: These are just sample commands. You can add more commands by creating new folders in the src/commands directory.
Follow the discord.js guide on how to create commands and look at the discord.js docs for more information.
TypeScript knowledge is required if you plan on making changes to this project.
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.
Any changes that you make be tested and functional before opening a pull request. Any pull requests that are not tested and functional will be closed.
This project is licensed under the GNU General Public License v3.0
- see the LICENSE.md file for details