discord-easy
v2.1.7
Published
`DiscordEasy` is a simplified module for creating Discord bots using `discord.js`. It allows easy management of message commands and slash commands, as well as adding events to your bot.
Downloads
103
Readme
DiscordEasy
DiscordEasy is a JavaScript module that simplifies the development of Discord bots using discord.js. It makes it easy to manage commands, events, and interact with a database.
Table of Contents
- Features
- Installation
- Usage
- Commands and Events
- Database Connection
- Intent Configuration
- Enable/Disable Debugging
- Contributing
Features
- Easy management of message commands and slash commands.
- Built-in event system to handle Discord events.
- Optional MySQL database connection.
- Support for custom intents.
- Debug mode for better log visibility.
Installation
Clone this repository or download the files.
Install the dependencies using npm:
npm install discord.js mysql2 nyx-logger
Make sure you have a Discord bot set up and retrieve your token, client ID, and guild ID.
Usage
- Here’s a basic example of how to create a bot with DiscordEasy:
const { GatewayIntentBits } = require('discord.js');
const DiscordEasy = require('discord-easy');
const bot = new DiscordEasy(
'YOUR_BOT_TOKEN', // Token
'YOUR_CLIENT_ID', // Client ID
'YOUR_GUILD_ID', // Guild ID
'!', // Prefix for message commands
true, // Enable slash commands
true // Enable message commands
);
// Add databse
bot.addDatabase("your_host", "your_user", "your_password", "your_database"); // Not nessecary
// Add custom intents
bot.addIntents(GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildMembers);
// Set the path for commands and events
bot.setPath('command', './commands');
bot.setPath('event', './events');
// Run the bot
bot.run();
Commands and Events
- Adding a Message Command to add a message command, create a JavaScript file in the commands folder:
module.exports = {
name: 'hello',
execute(message) {
message.channel.send('Hello, World!');
}
};
Adding an Event
- To add an event, create a JavaScript file in the events folder:
module.exports = {
name: 'ready',
register(bot) {
bot.client.on('ready', () => {
console.log.print('Bot is online!');
});
}
};
Database Connection
- If you want to connect your bot to a MySQL database, use the addDatabase method:
bot.addDatabase("your_host", "your_user", "your_password", "your_database");
Intent Configuration
- To add additional intents, use the addIntents method:
bot.addIntents(GatewayIntentBits.GuildMembers);
Contributing
- Contributions are welcome! If you have suggestions or want to add new features, feel free to open an issue or submit a pull request.