Link all top-level commands with macro recording/replaying logic
This commit is contained in:
43
src/hooks.rs
43
src/hooks.rs
@ -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;
|
||||
|
Reference in New Issue
Block a user