This README provides a guide for setting up a simple Discord bot using the DiscordEasy module. The bot is configured to use message commands and slash commands with basic intents.
- Features
- Prerequisites
- Installation
- Usage
- Commands and Events
- Database Connection
- Adding Intents
- Contributing
- Easy integration of message and slash commands.
- Customizable intents for better bot functionality.
- Simplified event management for Discord events.
Before you start, ensure you have the following installed:
- Node.js (version 16 or higher recommended)
- A Discord account with permissions to create bots.
- A Discord server where you can test the bot.
- Clone this repository or create a new project directory.
npm install discord.js discord-easy
- Token
- Client ID
- Guild ID
- Here's a basic example of how to set up your Discord bot using the DiscordEasy module:
const { Guild } = require('discord.js');
const DiscordEasy = require('discord-easy');
const { GatewayIntentBits } = require('discord.js');
const bot = new DiscordEasy(
'YOUR_BOT_TOKEN', // Replace with your Bot Token
'YOUR_CLIENT_ID', // Replace with your Client ID
'YOUR_GUILD_ID', // Replace with your Guild ID
'!', // Prefix for message commands
true, // Enable slash commands
true // Enable message commands
);
// Add a database connection (optional)
bot.addDatabase("your_host", "your_user", "your_password", "your_database");
// Add intents to the bot
bot.addIntents(GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildMembers); // Add necessary intents
// Set the paths for your command and event handlers
bot.setPath('command', './commands');
bot.setPath('event', './events');
bot.run();
- Important Configuration
- Token: Ensure you replace YOUR_BOT_TOKEN with the actual token from your Discord bot.
- Client ID: Replace YOUR_CLIENT_ID with your bot's client ID.
- Guild ID: Replace YOUR_GUILD_ID with your server's ID.
- To add commands and events, create JavaScript files in the commands and events folders, respectively.
module.exports = {
name: 'hello',
execute(message) {
message.channel.send('Hello, World!');
}
};
module.exports = {
name: 'hello',
description: 'hello world',
execute(interaction) {
interaction.reply('Hello, World!');
}
};
- In events/ready.js:
module.exports = {
name: 'ready',
register(bot) {
bot.client.on('ready', () => {
console.log('Bot is online!');
});
}
};
- If you wish to connect to a database, uncomment the addDatabase line and fill in your database details:
bot.addDatabase("your_host", "your_user", "your_password", "your_database");
- You can add more intents as needed using the addIntents method. For example, to add Guild Messages intent:
bot.addIntents(GatewayIntentBits.GuildMessages);
- Contributions are welcome! If you have suggestions or want to add new features, feel free to open an issue or submit a pull request.