Link all top-level commands with macro recording/replaying logic
This commit is contained in:
1 parent
5e39e16060
commit
76a286076b
25 files changed
+619
-410
No files matched your search
+17
-10
@@ -15,7 +15,7 @@ use crate::{
|
||||
},
|
||||
consts::{EMBED_DESCRIPTION_MAX_LENGTH, SELECT_MAX_ENTRIES, THEME_COLOR},
|
||||
models::{reminder::Reminder, CtxData},
|
||||
utils::Extract,
|
||||
utils::{Extract, Recordable},
|
||||
Context, Error,
|
||||
};
|
||||
|
||||
@@ -140,21 +140,28 @@ pub fn show_delete_page(reminders: &[Reminder], page: usize, timezone: Tz) -> Cr
|
||||
#[derive(Serialize, Deserialize, Extract)]
|
||||
pub struct Options;
|
||||
|
||||
pub async fn delete(ctx: Context<'_>, _options: Options) -> Result<(), Error> {
|
||||
let timezone = ctx.timezone().await;
|
||||
impl Recordable for Options {
|
||||
async fn run(self, ctx: Context<'_>) -> Result<(), Error> {
|
||||
let timezone = ctx.timezone().await;
|
||||
|
||||
let reminders =
|
||||
Reminder::from_guild(&ctx, &ctx.data().database, ctx.guild_id(), ctx.author().id).await;
|
||||
let reminders =
|
||||
Reminder::from_guild(&ctx, &ctx.data().database, ctx.guild_id(), ctx.author().id).await;
|
||||
|
||||
let resp = show_delete_page(&reminders, 0, timezone);
|
||||
let resp = show_delete_page(&reminders, 0, timezone);
|
||||
|
||||
ctx.send(resp).await?;
|
||||
ctx.send(resp).await?;
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete reminders
|
||||
#[poise::command(slash_command, rename = "del", default_member_permissions = "MANAGE_GUILD")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "delete",
|
||||
identifying_name = "delete",
|
||||
default_member_permissions = "MANAGE_GUILD"
|
||||
)]
|
||||
pub async fn command(ctx: Context<'_>) -> Result<(), Error> {
|
||||
delete(ctx, Options {}).await
|
||||
(Options {}).run(ctx).await
|
||||
}
|
||||
Reference in new issue
Block a user