Installation¶
Development Version Warning
rustycord is currently in heavy development and is NOT ready for production use.
- 🚨 Breaking changes occur frequently
- 🚨 APIs are unstable and will change
- 🚨 Features are incomplete
- 🚨 Not suitable for production bots
Only use for learning, experimentation, and development. Do not deploy bots using this library to production environments.
Development Status
This library is actively being developed. While basic functionality works, many features are missing or incomplete. Check the GitHub repository for the latest status.
Prerequisites¶
Before installing rustycord, make sure you have:
- Rust 1.70.0 or later - Install Rust
- Git - For cloning repositories
- Discord Bot Token - Create a Discord Application
Installing Rust¶
If you don't have Rust installed, you can install it using rustup:
Verify your installation:
Creating a New Project¶
Create a new Rust project for your Discord bot:
Adding rustycord Dependency¶
Add rustycord and required dependencies to your Cargo.toml
:
[package]
name = "my-discord-bot"
version = "0.1.0"
edition = "2021"
[dependencies]
rustycord = "0.1.0"
tokio = { version = "1.40", features = ["full"] }
async-trait = "0.1"
log = "0.4"
Setting Up Your Discord Bot¶
1. Create a Discord Application¶
- Go to the Discord Developer Portal
- Click "New Application"
- Give your application a name
- Navigate to the "Bot" section
- Click "Add Bot"
- Copy your bot token (keep this secret!)
2. Configure Bot Permissions¶
In the "Bot" section of your application:
- Enable the following Privileged Gateway Intents:
- Message Content Intent (if you need to read message content)
- Server Members Intent (if you need member information)
-
Presence Intent (if you need presence information)
-
In the "OAuth2" > "URL Generator" section:
- Select "bot" scope
-
Select required permissions:
- Send Messages
- Read Message History
- Use Slash Commands (if needed)
-
Use the generated URL to invite your bot to a server
3. Set Up Environment Variables¶
Create a .env
file in your project root:
Add .env
to your .gitignore
:
Verifying Installation¶
Create a simple test bot in src/main.rs
:
use rustycord::{Bot, Client, logger};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables
dotenv::dotenv().ok();
// Initialize logging
logger::setup_logger(logger::LogLevel::Info)?;
// Get bot token
let token = std::env::var("DISCORD_TOKEN")
.expect("DISCORD_TOKEN environment variable not set");
// Create client and bot
println!("Creating Discord client...");
let client = Client::new(&token).await?;
println!("Starting bot...");
let bot = Bot::new(client);
bot.start().await?;
Ok(())
}
Add the dotenv
dependency to your Cargo.toml
:
Run your bot:
You should see log output indicating your bot has connected to Discord!
Next Steps¶
Now that you have rustycord installed and a basic bot running:
- Create Your First Bot - Build a simple echo bot
- Bot Configuration - Learn about bot settings
- Message Handlers - Handle user messages
Troubleshooting¶
Common Issues¶
Bot token is invalid:
- Verify your bot token is correct - Make sure there are no extra spaces in your.env
file
Permission denied:
- Check that your bot has the required permissions in the Discord server - Verify the bot is properly invited to the serverConnection timeout:
- Check your internet connection - Verify Discord's status at discordstatus.comGetting Help¶
If you encounter issues:
- Check the troubleshooting guide
- Search GitHub Issues
- Create a new issue with:
- Your Rust version (
rustc --version
) - Your operating system
- Complete error messages
- Minimal reproduction code