generated from BrandonTheDev/discordjs-template
No description
| commands | Refactor OTD sources, add phobia and act of kindness OTDs, and remove unused commands and events. | |
| config | Refactor OTD sources, add phobia and act of kindness OTDs, and remove unused commands and events. | |
| events | Refactor OTD sources, add phobia and act of kindness OTDs, and remove unused commands and events. | |
| utils | Refactor OTD sources, add phobia and act of kindness OTDs, and remove unused commands and events. | |
| .gitignore | Start.bat used for server | |
| index.js | Use applicationCommands route instead of applicationGuildCommands. | |
| LICENSE | Initial commit | |
| package-lock.json | Init | |
| package.json | Init | |
| README.md | Initial commit | |
Discord.js Bot Template
A simple and modular Discord bot template built with Discord.js v14. This template provides a foundation for creating a Discord bot with slash commands and event handling, making it easy to extend with additional features.
Features
- Slash Command Support: Includes a
/pingcommand as an example, with a modular command structure. - Event Handling: Pre-configured event listeners for
ready,interactionCreate,messageCreate, andguildMemberAdd. - Configuration Management: Centralized settings in
config/settings.jsfor bot customization. - Environment Variables: Uses
dotenvfor secure management of sensitive data like the Discord bot token. - MIT License: Freely use, modify, and distribute the code under the MIT license.
Prerequisites
- Node.js: Version 18 or higher.
- Discord Bot Token: Obtainable from the Discord Developer Portal.
- Basic Knowledge: Familiarity with JavaScript, Node.js, and Discord.js.
Setup
-
Clone the Repository:
git clone <repository-url> cd wranglerbot -
Install Dependencies:
npm install -
Configure Environment Variables:
- Create a
.envfile in the root directory. - Add your Discord bot token:
DISCORD_TOKEN=your-bot-token-here
- Create a
-
Update Configuration:
- Open
config/settings.jsand update the following:bot.clientID: Your bot's client ID from the Discord Developer Portal.bot.guildID: The ID of the guild (server) where you want to deploy slash commands.bot.color: Customize the bot's embed color (hex code).
- Open
-
Run the Bot:
npm start
Project Structure
wranglerbot/
├── commands/
│ └── util/
│ └── ping.js # Example slash command
├── config/
│ └── settings.js # Bot configuration
├── events/
│ ├── guildMemberAdd.js # Handles new member events
│ ├── interactionCreate.js # Handles slash command interactions
│ ├── messageCreate.js # Handles message events
│ └── ready.js # Handles bot ready event
├── .env # Environment variables (not tracked)
├── index.js # Main bot entry point
├── LICENSE # MIT License
├── package.json # Project dependencies and scripts
├── package-lock.json # Dependency lock file
└── README.md # This file
Usage
- Slash Commands: The template includes a
/pingcommand that responds with "Pong!" and the bot's configured color. Add more commands by creating new files in thecommands/directory, following the structure ofping.js. - Events: Extend event functionality by modifying the files in the
events/directory. For example, add welcome messages inguildMemberAdd.js. - Deploying Commands: Slash commands are automatically deployed to the specified guild when the bot starts.
Adding New Commands
- Create a new file in the
commands/directory (e.g.,commands/util/newcommand.js). - Follow the structure of
ping.js:const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('newcommand') .setDescription('Description of your command'), async execute(interaction, settings) { await interaction.reply('Your command response!'); }, }; - The command will be automatically loaded and deployed when you restart the bot.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to improve the template.
License
This project is licensed under the MIT License. See the LICENSE file for details.