A starter template for building Discord bots with discord.js.
/ping: Replies with "Pong!". A good way to check if the bot is alive./echo [message]: Replies with the message you provide./roll [dice]: Rolls dice. You can specify the number of dice and sides in the formatd20or2d6.
- Node.js (v16.9.0 or higher)
- A Discord bot token. You can get one from the Discord Developer Portal.
- Clone this repository.
- Install the dependencies:
npm install
- Create a
.envfile in the root of the project and add your bot token and client ID:TOKEN=your_token_here CLIENT_ID=your_client_id_here - Deploy the commands to your server:
npm run deploy
- Run the bot:
npm start
- Create a new file in the
commandsdirectory. The filename will be the command name. - In the new file, export a
dataobject and anexecutefunction. See the existing commands for examples. - The
dataobject should be aSlashCommandBuilderinstance that defines the command's name, description, and options. - The
executefunction will be called when the command is used. It receives aninteractionobject as an argument. - After creating your new command file, you'll need to re-run the deploy script to register it with Discord:
npm run deploy