help command rework

This commit is contained in:
2020-11-30 21:55:34 +00:00
parent 268fcab8c5
commit 167a5a404f
4 changed files with 91 additions and 17 deletions

View File

@ -12,6 +12,7 @@ use serenity::{
use std::fmt;
use crate::{
consts::THEME_COLOR,
models::{GuildData, UserData},
SQLPool,
};
@ -458,15 +459,29 @@ async fn show_help(ctx: &Context, msg: &Message, target: Option<TodoTarget>) {
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
let prefix = GuildData::prefix_from_id(msg.guild_id, &pool).await;
let content = lm
.get(&user_data.language, "todo/help")
.replace("{prefix}", &prefix)
.replace(
"{command}",
target
.map_or_else(|| "todo user".to_string(), |t| t.command(None))
.as_str(),
);
let command = match target {
None => "help/todo",
Some(t) => {
if t.channel.is_some() {
"help/todoc"
} else if t.guild.is_some() {
"help/todos"
} else {
"help/todo"
}
}
};
let _ = msg.channel_id.say(&ctx, content).await;
let desc = lm.get(&user_data.language, command);
let _ = msg
.channel_id
.send_message(ctx, |m| {
m.embed(move |e| {
e.title("Todo Help")
.description(desc.replace("{prefix}", &prefix))
.color(*THEME_COLOR)
})
})
.await;
}