stub of new remind command
This commit is contained in:
parent
2c91a72640
commit
bf34721e55
@ -50,6 +50,7 @@ use std::{
|
|||||||
use crate::models::{CtxGuildData, MeridianType};
|
use crate::models::{CtxGuildData, MeridianType};
|
||||||
use regex::Captures;
|
use regex::Captures;
|
||||||
use serenity::model::channel::Channel;
|
use serenity::model::channel::Channel;
|
||||||
|
use serenity::model::interactions::Interaction;
|
||||||
|
|
||||||
fn shorthand_displacement(seconds: u64) -> String {
|
fn shorthand_displacement(seconds: u64) -> String {
|
||||||
let (days, seconds) = seconds.div_rem(&DAY);
|
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>>(
|
async fn create_reminder<'a, U: Into<u64>, T: TryInto<i64>>(
|
||||||
ctx: impl CacheHttp + AsRef<Cache>,
|
ctx: impl CacheHttp + AsRef<Cache>,
|
||||||
pool: &MySqlPool,
|
pool: &MySqlPool,
|
||||||
|
31
src/main.rs
31
src/main.rs
@ -212,6 +212,7 @@ DELETE FROM guilds WHERE guild = ?
|
|||||||
"info" => info_cmds::info_interaction(&ctx, interaction).await,
|
"info" => info_cmds::info_interaction(&ctx, interaction).await,
|
||||||
"donate" => info_cmds::donate_interaction(&ctx, interaction).await,
|
"donate" => info_cmds::donate_interaction(&ctx, interaction).await,
|
||||||
"clock" => info_cmds::clock_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
|
.await
|
||||||
.unwrap();
|
.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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user