Better infos

This commit is contained in:
Oupson 2020-08-24 21:24:39 +02:00
parent b9627ba69b
commit 1deef4a08f
2 changed files with 38 additions and 18 deletions

View File

@ -155,23 +155,44 @@ async fn _older(ctx: &Context, msg: &Message, mut args: Args) -> crate::commands
#[command] #[command]
#[description = "Print bot infos"] #[description = "Print bot infos"]
async fn infos(ctx: &Context, msg: &Message) -> CommandResult { async fn infos(ctx: &Context, msg: &Message) -> CommandResult {
let res = format!( let current_user = ctx.http.get_current_user().await;
"{} v{}, by {}\nFeatures : {:?}\nMode : {}", msg.channel_id
option_env!("CARGO_PKG_NAME").unwrap_or("unknown"), .send_message(ctx, |m| {
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"), m.embed(|e| {
option_env!("CARGO_PKG_AUTHORS").unwrap_or("unknows"), e.title(format!(
get_features(), "{} v{}, by {}",
{ option_env!("CARGO_PKG_NAME").unwrap_or("unknown"),
if cfg!(debug_assertions) { option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"),
"debug" option_env!("CARGO_PKG_AUTHORS").unwrap_or("unknows")
} else { ))
"release" .description(format!(
} concat!(
} "Features : {:?}\n",
); "Mode : {}\n",
if let Err(e) = api::send_splitted_by_lines_in_card(ctx, msg, res).await { "Source code : https://git.oupsman.fr/oupson/discord_rusty_bot"
eprintln!("Error when sending bot infos : {:?}", e); ),
} get_features(),
if cfg!(debug_assertions) {
"debug"
} else {
"release"
},
))
.colour((247, 76, 0))
.footer(|f| {
if let Ok(user) = &current_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(()) Ok(())
} }

View File

@ -115,7 +115,6 @@ fn bullet_to_str<'m>(nbr: u8) -> &'m str {
} }
} }
// TODO ALLOW ADMINS TO DISABLE THAT // TODO ALLOW ADMINS TO DISABLE THAT
#[command] #[command]
#[description = "DO IT"] #[description = "DO IT"]