stub of new remind command

This commit is contained in:
jellywx 2021-05-13 18:19:14 +01:00
parent 2c91a72640
commit bf34721e55
2 changed files with 45 additions and 0 deletions

View File

@ -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<u64>, T: TryInto<i64>>(
ctx: impl CacheHttp + AsRef<Cache>,
pool: &MySqlPool,

View File

@ -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();
}
}