From 0150fce1af73affcbe0d58a439fc7277be027059 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sat, 2 Aug 2025 19:47:29 -0500 Subject: about command --- src/main.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 37d9a75..0b34f30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ use twilight_model::{ use twilight_util::builder::{ InteractionResponseDataBuilder, command::{CommandBuilder, IntegerBuilder, RoleBuilder, StringBuilder, SubCommandBuilder}, - embed::EmbedBuilder, + embed::{EmbedBuilder, EmbedFieldBuilder}, }; mod brain; @@ -32,8 +32,9 @@ mod database; mod import; const PROD_APP_ID: u64 = 1363055126264283136; +#[allow(dead_code)] const DEV_APP_ID: u64 = 1363494986699771984; -const APP_ID: u64 = PROD_APP_ID; +const APP_ID: u64 = DEV_APP_ID; macro_rules! bail { ($msg:expr) => { @@ -163,6 +164,7 @@ async fn handle_event(event: Event, brain: Arc) -> Result<(), Box Commands::About, "leaderboard" => Commands::Leaderboard, "points" => Commands::Points, "permission" => Commands::Permission, @@ -183,6 +185,13 @@ async fn handle_event(event: Event, brain: Arc) -> Result<(), Box Vec { + let about = CommandBuilder::new( + "about", + "Get information about the bot", + CommandType::ChatInput, + ) + .build(); + let leaderboard = CommandBuilder::new( "leaderboard", "View the server leaderboard", @@ -221,7 +230,7 @@ async fn commands() -> Vec { ) .build(); - vec![leaderboard, points, permission, import] + vec![about, leaderboard, points, permission, import] } async fn command_handler( @@ -233,6 +242,7 @@ async fn command_handler( ) { // Handle the command and create our interaction response data let data = match command { + Commands::About => about(brain.clone(), guild), Commands::Leaderboard => get_leaderboard(brain.clone(), guild), Commands::Points => add_points(brain.clone(), guild, create, command_data).await, Commands::Permission => permission(brain.clone(), guild, create, command_data).await, @@ -246,6 +256,20 @@ async fn command_handler( brain.interaction_respond(create, data).await; } +fn about(_brain: Arc, _guild: Id) -> InteractionResponseData { + let embed = EmbedBuilder::new() + .title("About Leaberblord") + .description( + "A single-purpose bot for keeping score. Written in Rust using the twilight set of crates.", + ).field(EmbedFieldBuilder::new("Source", "The source is available on the author's [cgit instance](https://git.dreamy.place/whimsy/leaberblord/about)")) + .field(EmbedFieldBuilder::new("Author", "Written by @gennyble. Her homepage is [dreamy.place](https://dreamy.place)")) + .color(0x33aa88).build(); + + InteractionResponseDataBuilder::new() + .embeds([embed]) + .build() +} + fn get_leaderboard(brain: Arc, guild: Id) -> InteractionResponseData { let board = brain.db.get_leaderboard(guild.get()); @@ -449,6 +473,7 @@ async fn import_cmd( } enum Commands { + About, Leaderboard, Points, Permission, -- cgit 1.4.1-3-g733a5