Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ log = "0.4.29"
mime = "0.3.17"
mime_guess = "2.0.5"
poise = "0.6.1"
rand = "0.9.2"
reqwest = { version = "0.12.28", default-features = false, features = [
"json",
"rustls-tls",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LeoGPT

A Discord bot that connects to AI models through OpenRouter. Mention the bot in any channel to chat with it.
LeoGPT is a Discord bot for fast, context-aware chat with media support, tool-driven web search and generation, auto-responses, and voice-channel music playback.

<img src="assets/icon.png" alt="LeoGPT icon" width="256">

Expand Down
7 changes: 6 additions & 1 deletion src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
error::{BotError, Result},
music::{S3MusicStore, music_commands},
openrouter::OpenRouterClient,
react::react_commands,
};

type EventResult = Result<()>;
Expand Down Expand Up @@ -97,7 +98,11 @@ pub async fn run() -> Result<()> {
debug!("Building framework");
let framework = Framework::builder()
.options(FrameworkOptions {
commands: music_commands(),
commands: {
let mut commands = music_commands();
commands.extend(react_commands());
commands
},
event_handler: |ctx, event, _framework, data| Box::pin(event_handler(ctx, event, data)),
on_error: |error| Box::pin(on_error(error)),
..Default::default()
Expand Down
6 changes: 6 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pub enum BotError {
#[error("Music storage not configured")]
MusicNotConfigured,

#[error("Reaction image list is empty")]
ReactionImagesEmpty,

#[error("S3 error: {0}")]
S3(String),

Expand Down Expand Up @@ -192,6 +195,9 @@ impl BotError {
BotError::MusicNotConfigured => {
"Music playback is not configured on this bot.".to_string()
}
BotError::ReactionImagesEmpty => {
"No reaction images are configured right now.".to_string()
}
BotError::S3(_) | BotError::S3Sdk(_) | BotError::S3PresignConfig(_) => {
"Sorry, I encountered a problem fetching music from storage.".to_string()
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod error;
pub mod media;
pub mod music;
pub mod openrouter;
mod react;
pub mod tools;
pub mod types;

Expand Down
36 changes: 36 additions & 0 deletions src/react.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//! Slash command for random reaction images.

use rand::prelude::IndexedRandom;

use crate::{
bot::Data,
error::{BotError, Result},
};

/// Context type for reaction command.
type Context<'a> = poise::Context<'a, Data, BotError>;

const REACTION_IMAGES: &[&str] = &[
"https://vault-public.s3.ca-east-006.backblazeb2.com/media/memes/enhanced/an_iq_too_high.png",
"https://vault-public.s3.ca-east-006.backblazeb2.com/media/memes/enhanced/does_he_know.png",
"https://vault-public.s3.ca-east-006.backblazeb2.com/media/memes/enhanced/he_made_a_statement_so_trash_even_his_gang_clowed_him.png",
"https://vault-public.s3.ca-east-006.backblazeb2.com/media/memes/enhanced/why_is_he_lying.png",
];

/// Send a random reaction image.
#[poise::command(slash_command)]
pub async fn react(ctx: Context<'_>) -> Result<()> {
let url = REACTION_IMAGES
.choose(&mut rand::rng())
.copied()
.ok_or(BotError::ReactionImagesEmpty)?;

ctx.say(url).await?;
Ok(())
}

/// Get available reaction commands.
#[must_use]
pub fn react_commands() -> Vec<poise::Command<Data, BotError>> {
vec![react()]
}