From 1deef4a08fe597068ac7cfcde25d9a5332e938c7 Mon Sep 17 00:00:00 2001 From: Oupson Date: Mon, 24 Aug 2020 21:24:39 +0200 Subject: [PATCH] Better infos --- src/commands/general.rs | 55 +++++++++++++++++++++++++++------------- src/commands/roulette.rs | 1 - 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/commands/general.rs b/src/commands/general.rs index 7cdeb61..52d3b3c 100644 --- a/src/commands/general.rs +++ b/src/commands/general.rs @@ -155,23 +155,44 @@ async fn _older(ctx: &Context, msg: &Message, mut args: Args) -> crate::commands #[command] #[description = "Print bot infos"] async fn infos(ctx: &Context, msg: &Message) -> CommandResult { - let res = format!( - "{} v{}, by {}\nFeatures : {:?}\nMode : {}", - option_env!("CARGO_PKG_NAME").unwrap_or("unknown"), - option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"), - option_env!("CARGO_PKG_AUTHORS").unwrap_or("unknows"), - get_features(), - { - if cfg!(debug_assertions) { - "debug" - } else { - "release" - } - } - ); - if let Err(e) = api::send_splitted_by_lines_in_card(ctx, msg, res).await { - eprintln!("Error when sending bot infos : {:?}", e); - } + let current_user = ctx.http.get_current_user().await; + msg.channel_id + .send_message(ctx, |m| { + m.embed(|e| { + e.title(format!( + "{} v{}, by {}", + option_env!("CARGO_PKG_NAME").unwrap_or("unknown"), + option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"), + option_env!("CARGO_PKG_AUTHORS").unwrap_or("unknows") + )) + .description(format!( + concat!( + "Features : {:?}\n", + "Mode : {}\n", + "Source code : https://git.oupsman.fr/oupson/discord_rusty_bot" + ), + get_features(), + if cfg!(debug_assertions) { + "debug" + } else { + "release" + }, + )) + .colour((247, 76, 0)) + .footer(|f| { + if let Ok(user) = ¤t_user { + let mut f = f.text(&user.name); + if let Some(avatar) = user.avatar_url() { + f = f.icon_url(avatar); + } + f + } else { + f + } + }) + }) + }) + .await?; Ok(()) } diff --git a/src/commands/roulette.rs b/src/commands/roulette.rs index ed5a41b..48b3c3a 100644 --- a/src/commands/roulette.rs +++ b/src/commands/roulette.rs @@ -115,7 +115,6 @@ fn bullet_to_str<'m>(nbr: u8) -> &'m str { } } - // TODO ALLOW ADMINS TO DISABLE THAT #[command] #[description = "DO IT"]