diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index df3e375..4ed6439 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -50,6 +50,7 @@ use std::{ use crate::models::{CtxGuildData, MeridianType}; use regex::Captures; use serenity::model::channel::Channel; +use serenity::model::interactions::Interaction; fn shorthand_displacement(seconds: u64) -> String { let (days, seconds) = seconds.div_rem(&DAY); @@ -1552,6 +1553,19 @@ async fn natural(ctx: &Context, msg: &Message, args: String) { } } +pub async fn set_reminder(ctx: &Context, interaction: Interaction) { + let (pool, lm) = get_ctx_data(&ctx).await; + + let now = SystemTime::now(); + let since_epoch = now + .duration_since(UNIX_EPOCH) + .expect("Time calculated as going backwards. Very bad"); + + let user_data = UserData::from_user(&interaction.member.user, &ctx, &pool) + .await + .unwrap(); +} + async fn create_reminder<'a, U: Into, T: TryInto>( ctx: impl CacheHttp + AsRef, pool: &MySqlPool, diff --git a/src/main.rs b/src/main.rs index 1dbc7f8..a0cbd04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -212,6 +212,7 @@ DELETE FROM guilds WHERE guild = ? "info" => info_cmds::info_interaction(&ctx, interaction).await, "donate" => info_cmds::donate_interaction(&ctx, interaction).await, "clock" => info_cmds::clock_interaction(&ctx, interaction).await, + "remind" => reminder_cmds::set_reminder(&ctx, interaction).await, _ => {} } } @@ -521,6 +522,36 @@ async fn create_interactions( }) .await .unwrap(); + + guild_id + .create_application_command(&http, app_id, |command| { + command + .name("remind") + .description("Set a reminder") + .create_interaction_option(|option| { + option + .name("message") + .description("Message to send with the reminder") + .kind(ApplicationCommandOptionType::String) + .required(true) + }) + .create_interaction_option(|option| { + option + .name("time") + .description("Time to send the reminder") + .kind(ApplicationCommandOptionType::String) + .required(true) + }) + .create_interaction_option(|option| { + option + .name("channel") + .description("Channel to send reminder to (default: this channel)") + .kind(ApplicationCommandOptionType::Channel) + .required(false) + }) + }) + .await + .unwrap(); } }