help command now no longer relies on help_strings const
timeparser updated to work with partially specified times
This commit is contained in:
@ -6,14 +6,16 @@ use chrono::offset::Utc;
|
||||
|
||||
use crate::{
|
||||
command_help,
|
||||
consts::{DEFAULT_PREFIX, HELP_STRINGS},
|
||||
consts::DEFAULT_PREFIX,
|
||||
get_ctx_data,
|
||||
language_manager::LanguageManager,
|
||||
models::{GuildData, UserData},
|
||||
THEME_COLOR,
|
||||
FrameworkCtx, THEME_COLOR,
|
||||
};
|
||||
|
||||
use crate::framework::RegexFramework;
|
||||
use serenity::builder::CreateEmbedFooter;
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
@ -110,14 +112,24 @@ async fn help(ctx: &Context, msg: &Message, args: String) {
|
||||
let prefix = GuildData::prefix_from_id(msg.guild_id, &pool);
|
||||
|
||||
if !args.is_empty() {
|
||||
let matched = HELP_STRINGS
|
||||
.iter()
|
||||
.filter(|h| h.split_at(5).1 == args)
|
||||
.next();
|
||||
let framework: Arc<Box<RegexFramework>> = {
|
||||
let framework_trait = ctx
|
||||
.data
|
||||
.read()
|
||||
.await
|
||||
.get::<FrameworkCtx>()
|
||||
.cloned()
|
||||
.expect("Could not get FrameworkCtx from data");
|
||||
|
||||
if let Some(help_str) = matched {
|
||||
let command_name = help_str.split_at(5).1;
|
||||
unsafe { mem::transmute(framework_trait.clone()) }
|
||||
};
|
||||
|
||||
let matched = framework
|
||||
.commands
|
||||
.get(args.as_str())
|
||||
.map(|inner| inner.name);
|
||||
|
||||
if let Some(command_name) = matched {
|
||||
command_help(ctx, msg, lm, &prefix.await, &language.await, command_name).await
|
||||
} else {
|
||||
default_help(ctx, msg, lm, &prefix.await, &language.await).await;
|
||||
|
@ -215,7 +215,7 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) {
|
||||
}
|
||||
}
|
||||
|
||||
#[command]
|
||||
#[command("meridian")]
|
||||
async fn change_meridian(ctx: &Context, msg: &Message, args: String) {
|
||||
let (pool, lm) = get_ctx_data(&ctx).await;
|
||||
|
||||
@ -258,7 +258,7 @@ async fn change_meridian(ctx: &Context, msg: &Message, args: String) {
|
||||
}
|
||||
}
|
||||
|
||||
#[command]
|
||||
#[command("lang")]
|
||||
async fn language(ctx: &Context, msg: &Message, args: String) {
|
||||
let (pool, lm) = get_ctx_data(&ctx).await;
|
||||
|
||||
|
@ -982,14 +982,23 @@ impl Content {
|
||||
#[command("countdown")]
|
||||
#[permission_level(Managed)]
|
||||
async fn countdown(ctx: &Context, msg: &Message, args: String) {
|
||||
if !check_subscription_on_message(&ctx, &msg).await {
|
||||
} else {
|
||||
if check_subscription_on_message(&ctx, &msg).await {
|
||||
let (pool, lm) = get_ctx_data(&ctx).await;
|
||||
let timezone = UserData::timezone_of(&msg.author, &pool).await;
|
||||
|
||||
let split_args = args.splitn(3, ' ').collect::<Vec<&str>>();
|
||||
|
||||
if split_args.len() == 3 {
|
||||
let time = split_args.get(0).unwrap();
|
||||
let interval = split_args.get(1).unwrap();
|
||||
let event_name = split_args.get(2).unwrap();
|
||||
|
||||
let time_parser = TimeParser::new(*time, &timezone);
|
||||
|
||||
if let Ok(target_ts) = time_parser.timestamp() {}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -367,7 +367,7 @@ impl Execute for Result<SubCommand, ()> {
|
||||
}
|
||||
}
|
||||
|
||||
#[command]
|
||||
#[command("todo")]
|
||||
async fn todo_user(ctx: &Context, msg: &Message, args: String) {
|
||||
let mut split = args.split(' ');
|
||||
|
||||
@ -384,7 +384,7 @@ async fn todo_user(ctx: &Context, msg: &Message, args: String) {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[command("todos")]
|
||||
#[command("todoc")]
|
||||
#[supports_dm(false)]
|
||||
#[permission_level(Managed)]
|
||||
async fn todo_channel(ctx: &Context, msg: &Message, args: String) {
|
||||
|
Reference in New Issue
Block a user