Link all top-level commands with macro recording/replaying logic

This commit is contained in:
jude
2024-02-18 13:24:37 +00:00
parent 5e39e16060
commit 76a286076b
25 changed files with 619 additions and 410 deletions

View File

@ -13,18 +13,6 @@ async fn macro_check(ctx: Context<'_>) -> bool {
let mut lock = ctx.data().recording_macros.write().await;
if let Some(command_macro) = lock.get_mut(&(guild_id, ctx.author().id)) {
if ctx.command().identifying_name != "remind" {
let _ = ctx
.send(
CreateReply::default()
.ephemeral(true)
.content("Macro recording only supports `/remind`. Please stop recording with `/macro finish` before using other commands.")
)
.await;
return false;
}
if command_macro.commands.len() >= MACRO_MAX_COMMANDS {
let _ = ctx
.send(
@ -34,16 +22,29 @@ async fn macro_check(ctx: Context<'_>) -> bool {
)
.await;
} else {
let recorded = RecordedCommand::from_context(app_ctx).unwrap();
command_macro.commands.push(recorded);
match RecordedCommand::from_context(app_ctx) {
Some(recorded) => {
command_macro.commands.push(recorded);
let _ = ctx
.send(
CreateReply::default()
.ephemeral(true)
.content("Command recorded to macro"),
)
.await;
let _ = ctx
.send(
CreateReply::default()
.ephemeral(true)
.content("Command recorded to macro"),
)
.await;
}
None => {
let _ = ctx
.send(
CreateReply::default().ephemeral(true).content(
"This command is not supported in macros yet.",
),
)
.await;
}
}
}
return false;