fixed a lot of message formatting that had been ignored
This commit is contained in:
parent
1afa04d61c
commit
1f41343e2e
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -1,5 +1,15 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "Inflector"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "0.2.3"
|
||||
@ -1121,6 +1131,7 @@ dependencies = [
|
||||
name = "reminder_rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
|
@ -22,6 +22,7 @@ custom_error = "1.7.1"
|
||||
serde = "1.0.115"
|
||||
serde_json = "1.0.57"
|
||||
rand = "0.7.3"
|
||||
Inflector = "0.11.4"
|
||||
|
||||
[dependencies.regex_command_attr]
|
||||
path = "./regex_command_attr"
|
||||
|
@ -11,12 +11,14 @@ use serenity::{
|
||||
};
|
||||
|
||||
use chrono::offset::Utc;
|
||||
use chrono_tz::Tz;
|
||||
|
||||
use crate::{
|
||||
models::{
|
||||
UserData,
|
||||
GuildData,
|
||||
},
|
||||
THEME_COLOR,
|
||||
SQLPool,
|
||||
models::UserData,
|
||||
};
|
||||
|
||||
use std::time::{
|
||||
@ -65,7 +67,11 @@ async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
|
||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||
|
||||
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
||||
let desc = user_data.response(&pool, "info").await;
|
||||
let guild_data = GuildData::from_guild(msg.guild(&ctx).await.unwrap(), &pool).await.unwrap();
|
||||
|
||||
let desc = user_data.response(&pool, "info").await
|
||||
.replacen("{user}", &ctx.cache.current_user().await.name, 1)
|
||||
.replacen("{prefix}", &guild_data.prefix, 1);
|
||||
|
||||
msg.channel_id.send_message(ctx, |m| m
|
||||
.embed(move |e| e
|
||||
@ -117,9 +123,7 @@ async fn clock(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||
|
||||
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
||||
|
||||
let tz: Tz = user_data.timezone.parse().unwrap();
|
||||
|
||||
let now = Utc::now().with_timezone(&tz);
|
||||
let now = Utc::now().with_timezone(&user_data.timezone());
|
||||
|
||||
if args == "12" {
|
||||
let _ = msg.channel_id.say(&ctx, user_data.response(&pool, "clock/time").await.replacen("{}", &now.format("%I:%M:%S %p").to_string(), 1)).await;
|
||||
|
@ -18,6 +18,10 @@ use regex::Regex;
|
||||
|
||||
use chrono_tz::Tz;
|
||||
|
||||
use chrono::offset::Utc;
|
||||
|
||||
use inflector::Inflector;
|
||||
|
||||
use crate::{
|
||||
models::{
|
||||
ChannelData,
|
||||
@ -78,15 +82,21 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
||||
|
||||
let mut user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
|
||||
let guild_data = GuildData::from_guild(msg.guild(&ctx).await.unwrap(), &pool).await.unwrap();
|
||||
|
||||
if !args.is_empty() {
|
||||
match args.parse::<Tz>() {
|
||||
Ok(_) => {
|
||||
user_data.timezone = args;
|
||||
|
||||
user_data.commit_changes(&pool).await;
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, user_data.response(&pool, "timezone/set_p").await).await;
|
||||
let now = Utc::now().with_timezone(&user_data.timezone());
|
||||
|
||||
let content = user_data.response(&pool, "timezone/set_p").await
|
||||
.replacen("{timezone}", &user_data.timezone, 1)
|
||||
.replacen("{time}", &now.format("%H:%M").to_string(), 1);
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, content).await;
|
||||
}
|
||||
|
||||
Err(_) => {
|
||||
@ -95,7 +105,11 @@ async fn timezone(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let _ = msg.channel_id.say(&ctx, user_data.response(&pool, "timezone/no_argument").await).await;
|
||||
let content = user_data.response(&pool, "timezone/no_argument").await
|
||||
.replace("{prefix}", &guild_data.prefix)
|
||||
.replacen("{timezone}", &user_data.timezone, 1);
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, content).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -124,7 +138,19 @@ SELECT code FROM languages WHERE code = ? OR name = ?
|
||||
},
|
||||
|
||||
Err(_) => {
|
||||
let _ = msg.channel_id.say(&ctx, user_data.response(&pool, "lang/invalid").await).await;
|
||||
let language_codes = sqlx::query!("SELECT name, code FROM languages")
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|language| format!("{} ({})", language.name.to_title_case(), language.code.to_uppercase()))
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
|
||||
let content = user_data.response(&pool, "lang/invalid").await
|
||||
.replacen("{}", &language_codes, 1);
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, content).await;
|
||||
},
|
||||
}
|
||||
|
||||
@ -151,7 +177,10 @@ async fn prefix(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
||||
guild_data.prefix = args;
|
||||
guild_data.commit_changes(&pool).await;
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, user_data.response(&pool, "prefix/success").await).await;
|
||||
let content = user_data.response(&pool, "prefix/success").await
|
||||
.replacen("{prefix}", &guild_data.prefix, 1);
|
||||
|
||||
let _ = msg.channel_id.say(&ctx, content).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -437,7 +437,6 @@ WHERE
|
||||
reminder_ids.push(reminder.id);
|
||||
let time = user_data.timezone().timestamp(reminder.time as i64, 0);
|
||||
|
||||
// todo show reminder message instead of name
|
||||
format!("**{}**: '{}' *<#{}>* at {}", count + 1, reminder.content, reminder.channel, time.format("%Y-%m-%D %H:%M:%S"))
|
||||
});
|
||||
|
||||
|
@ -85,6 +85,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
|
||||
.add_command("help", &info_cmds::HELP_COMMAND)
|
||||
.add_command("info", &info_cmds::INFO_COMMAND)
|
||||
.add_command("invite", &info_cmds::INFO_COMMAND)
|
||||
.add_command("donate", &info_cmds::DONATE_COMMAND)
|
||||
.add_command("dashboard", &info_cmds::DASHBOARD_COMMAND)
|
||||
.add_command("clock", &info_cmds::CLOCK_COMMAND)
|
||||
|
Loading…
Reference in New Issue
Block a user