A complete, easy-to-use Discord bot template built with discord.js v14. Designed for beginners and advanced users alike, featuring a modular handler, slash commands, and built-in features like Music, Moderation, Fun, Giveaways, and Reaction Roles.
- Modular Handler: Easy to maintain and expand.
- Slash Commands: Modern Discord interactions.
- Music System: High-quality music playback using DisTube.
- Moderation: Kick, Ban, Purge.
- Fun Commands: Meme, 8ball.
- Giveaway System: Start, End, Reroll (JSON based).
- Admin Tools: Reaction Roles, Customizable Welcome/Leave messages.
- No Database Required: Uses simple JSON files out of the box.
- Node.js v16.9.0 or higher.
- A Discord Bot Token (Get one at Discord Java Developer Portal).
-
Clone the repository:
git clone https://github.com/yourusername/SimpleMultipurposeBot.git cd SimpleMultipurposeBot -
Install dependencies:
npm install
-
Configure the bot:
- Rename
.env.exampleto.env. - Open
.envand paste your Bot Token and Client ID.
TOKEN=your_super_secret_token_here CLIENT_ID=your_bot_client_id_here
- (Optional) detailed configuration in
config.js.
- Rename
-
Start the bot:
node src/index.js
Or for development with auto-restart:
npm run dev
- Make sure the bot has the "Manage Roles" permission and its role is ABOVE the role you want to give.
- Run the command:
/reactionrole role:@RoleName emoji:🎉 description:Click the emoji to get the role! - The bot will send an embed. Users can react to get/remove the role.
Welcome:
- Set Channel:
/setwelcome channel channel:#general - Set Message:
/setwelcome message text:Welcome {user} to {server}! Member #{count} - Enable DM:
/setwelcome dm enabled:true
Leave:
- Set Channel:
/setleave channel channel:#general - Set Message:
/setleave message text:Goodbye {user}!
Variables:
{user}- Mentions the user (or tag).{server}- Server name.{count}- Current member count.
-
Go to
src/commands. -
Create a new folder (category) or use an existing one.
-
Create a new
.jsfile (e.g.,ping.js). -
Use this template:
const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('commandname') .setDescription('Description of command'), async execute(interaction, client) { await interaction.reply('Hello World!'); }, };
-
Restart the bot! The handler automatically loads and registers the new command.
Currently, the bot uses JSON files in the /data folder for storage. This is great for small bots but can corrupt if multiple writes happen at once. For larger bots, use MongoDB.
-
Install Mongoose:
npm install mongoose
-
Connect to MongoDB:
- In
src/index.js, add this beforeclient.login():const mongoose = require('mongoose'); mongoose.connect(process.env.MONGO_URI) .then(() => console.log('Connected to MongoDB')) .catch(err => console.error(err));
- Add
MONGO_URIto your.envfile.
- In
-
Create Schemas:
- Create a
src/modelsfolder. - Example
Giveaway.js:const mongoose = require('mongoose'); module.exports = mongoose.model('Giveaway', new mongoose.Schema({ messageId: String, prize: String, // ... helper fields }));
- Create a
-
Update Commands:
- Instead of reading/writing JSON files using
fs, use the Mongoose models. - Example replacement in
start.js:const Giveaway = require('../../models/Giveaway'); // ... await Giveaway.create({ messageId: message.id, ... });
- Instead of reading/writing JSON files using
Feel free to fork this project and submit pull requests!
This project is licensed under the MIT License.