Skip to content

This Discord Bot is a starter kit built using Rust, designed to get you up and running with your own Discord bot that utilizes slash commands and integrates with OpenAI's powerful AI models.

Notifications You must be signed in to change notification settings

rfcku/Discord-Rust-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust

Rust Discord Bot Starter Kit

This Discord Bot is a starter kit built using Rust, designed to get you up and running with your own Discord bot that utilizes slash commands and integrates with OpenAI's powerful AI models. It's perfect for developers looking to explore Discord bot development with Rust's performance and safety features.

Features

  • Slash Commands: Easy to use slash commands for interaction within Discord.
  • OpenAI Integration: Leverage OpenAI's API to integrate AI-powered responses and functionalities.
  • Customizable: A clean codebase that's easy to extend with more commands and features.
  • Asynchronous: Built with async/await for efficient performance.

Getting Started

To get your Discord bot up and running, follow these steps:

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/rfcku/rust-bot-starter-kit/tree/main

cd rust-discord-bot-starter
  1. Configure Environment Variable

Rename .env.example to .env and fill in your Discord Bot Token and OpenAI API key.

    DISCORD_TOKEN=your_discord_bot_token_here
    OPENAI_API_KEY=your_openai_api_key_here
  1. Build and run

Compile and run the bot with Cargo.

cargo build
cargo run

Adding Commands

Usage After starting the bot, it will be online in your Discord server. You can interact with it using slash commands that you define.

Adding New Slash Commands To add a new slash command:

Define the command in src/commands.rs. Update the command handler in src/main.rs to include your new command. Integrating with OpenAI The starter kit includes a basic OpenAI integration example. To utilize

OpenAI's capabilities:

Use the provided OpenAI client in src/services/openai.rs to make requests. Process the OpenAI API responses according to your application's needs.

    use serenity::framework::standard::{
        macros::{command, group},
        CommandResult,
    };
    use serenity::model::prelude::*;
    use serenity::prelude::*;

    #[command]
    async fn your_command(ctx: &Context, msg: &Message) -> CommandResult {
        msg.channel_id.say(&ctx.http, "Hello, World!").await?;
        Ok(())
    }

Contributing

Contributions are welcome! Please feel free to submit pull requests, report bugs, or suggest features.

About

This Discord Bot is a starter kit built using Rust, designed to get you up and running with your own Discord bot that utilizes slash commands and integrates with OpenAI's powerful AI models.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages