add distinct identifying names. log errors in run_macro
This commit is contained in:
@ -28,7 +28,7 @@ async fn timezone_autocomplete(ctx: Context<'_>, partial: String) -> Vec<String>
|
||||
}
|
||||
|
||||
/// Select your timezone
|
||||
#[poise::command(slash_command)]
|
||||
#[poise::command(slash_command, identifying_name = "timezone")]
|
||||
pub async fn timezone(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Timezone to use from this list: https://gist.github.com/JellyWX/913dfc8b63d45192ad6cb54c829324ee"]
|
||||
@ -150,13 +150,23 @@ WHERE
|
||||
}
|
||||
|
||||
/// Record and replay command sequences
|
||||
#[poise::command(slash_command, rename = "macro", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "macro",
|
||||
check = "guild_only",
|
||||
identifying_name = "macro_base"
|
||||
)]
|
||||
pub async fn macro_base(_ctx: Context<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Start recording up to 5 commands to replay
|
||||
#[poise::command(slash_command, rename = "record", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "record",
|
||||
check = "guild_only",
|
||||
identifying_name = "record_macro"
|
||||
)]
|
||||
pub async fn record_macro(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Name for the new macro"] name: String,
|
||||
@ -235,7 +245,7 @@ Please use `/macro finish` to end this recording before starting another.",
|
||||
slash_command,
|
||||
rename = "finish",
|
||||
check = "guild_only",
|
||||
identifying_name = "macro_finish"
|
||||
identifying_name = "finish_macro"
|
||||
)]
|
||||
pub async fn finish_macro(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let key = (ctx.guild_id().unwrap(), ctx.author().id);
|
||||
@ -288,7 +298,12 @@ pub async fn finish_macro(ctx: Context<'_>) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
/// List recorded macros
|
||||
#[poise::command(slash_command, rename = "list", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "list",
|
||||
check = "guild_only",
|
||||
identifying_name = "list_macro"
|
||||
)]
|
||||
pub async fn list_macro(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let macros = ctx.command_macros().await?;
|
||||
|
||||
@ -304,7 +319,12 @@ pub async fn list_macro(ctx: Context<'_>) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
/// Run a recorded macro
|
||||
#[poise::command(slash_command, rename = "run", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "run",
|
||||
check = "guild_only",
|
||||
identifying_name = "run_macro"
|
||||
)]
|
||||
pub async fn run_macro(
|
||||
ctx: poise::ApplicationContext<'_, Data, Error>,
|
||||
#[description = "Name of macro to run"]
|
||||
@ -317,13 +337,17 @@ pub async fn run_macro(
|
||||
|
||||
for command in command_macro.commands {
|
||||
if let Some(action) = command.action {
|
||||
(action)(poise::ApplicationContext { args: &command.options, ..ctx })
|
||||
match (action)(poise::ApplicationContext { args: &command.options, ..ctx })
|
||||
.await
|
||||
.ok()
|
||||
.unwrap();
|
||||
{
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
println!("{:?}", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Context::Application(ctx)
|
||||
.say(format!("Command \"{}\" failed to execute", command.command_name))
|
||||
.say(format!("Command \"{}\" not found", command.command_name))
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
@ -338,7 +362,12 @@ pub async fn run_macro(
|
||||
}
|
||||
|
||||
/// Delete a recorded macro
|
||||
#[poise::command(slash_command, rename = "delete", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "delete",
|
||||
check = "guild_only",
|
||||
identifying_name = "delete_macro"
|
||||
)]
|
||||
pub async fn delete_macro(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Name of macro to delete"]
|
||||
|
@ -39,7 +39,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Pause all reminders on the current channel until a certain time or indefinitely
|
||||
#[poise::command(slash_command)]
|
||||
#[poise::command(slash_command, identifying_name = "pause")]
|
||||
pub async fn pause(
|
||||
ctx: Context<'_>,
|
||||
#[description = "When to pause until"] until: Option<String>,
|
||||
@ -90,7 +90,7 @@ pub async fn pause(
|
||||
}
|
||||
|
||||
/// Move all reminders in the current server by a certain amount of time. Times get added together
|
||||
#[poise::command(slash_command)]
|
||||
#[poise::command(slash_command, identifying_name = "offset")]
|
||||
pub async fn offset(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Number of hours to offset by"] hours: Option<isize>,
|
||||
@ -147,7 +147,7 @@ WHERE FIND_IN_SET(channels.`channel`, ?)",
|
||||
}
|
||||
|
||||
/// Nudge all future reminders on this channel by a certain amount (don't use for DST! See `/offset`)
|
||||
#[poise::command(slash_command)]
|
||||
#[poise::command(slash_command, identifying_name = "nudge")]
|
||||
pub async fn nudge(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Number of minutes to nudge new reminders by"] minutes: Option<isize>,
|
||||
@ -170,7 +170,7 @@ pub async fn nudge(
|
||||
}
|
||||
|
||||
/// View reminders on a specific channel
|
||||
#[poise::command(slash_command)]
|
||||
#[poise::command(slash_command, identifying_name = "look")]
|
||||
pub async fn look(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Channel to view reminders on"] channel: Option<Channel>,
|
||||
@ -260,7 +260,7 @@ pub async fn look(
|
||||
}
|
||||
|
||||
/// Delete reminders
|
||||
#[poise::command(slash_command, rename = "del")]
|
||||
#[poise::command(slash_command, rename = "del", identifying_name = "delete")]
|
||||
pub async fn delete(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let timezone = ctx.timezone().await;
|
||||
|
||||
@ -422,13 +422,13 @@ fn time_difference(start_time: NaiveDateTime) -> String {
|
||||
}
|
||||
|
||||
/// Manage timers
|
||||
#[poise::command(slash_command, rename = "timer")]
|
||||
#[poise::command(slash_command, rename = "timer", identifying_name = "timer_base")]
|
||||
pub async fn timer_base(_ctx: Context<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// List the timers in this server or DM channel
|
||||
#[poise::command(slash_command, rename = "list")]
|
||||
#[poise::command(slash_command, rename = "list", identifying_name = "list_timer")]
|
||||
pub async fn list_timer(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let owner = ctx.guild_id().map(|g| g.0).unwrap_or_else(|| ctx.author().id.0);
|
||||
|
||||
@ -452,7 +452,7 @@ pub async fn list_timer(ctx: Context<'_>) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
/// Start a new timer from now
|
||||
#[poise::command(slash_command, rename = "start")]
|
||||
#[poise::command(slash_command, rename = "start", identifying_name = "start_timer")]
|
||||
pub async fn start_timer(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Name for the new timer"] name: String,
|
||||
@ -482,7 +482,7 @@ pub async fn start_timer(
|
||||
}
|
||||
|
||||
/// Delete a timer
|
||||
#[poise::command(slash_command, rename = "delete")]
|
||||
#[poise::command(slash_command, rename = "delete", identifying_name = "delete_timer")]
|
||||
pub async fn delete_timer(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Name of timer to delete"] name: String,
|
||||
@ -509,8 +509,8 @@ pub async fn delete_timer(
|
||||
}
|
||||
|
||||
/// Create a new reminder
|
||||
#[poise::command(slash_command)]
|
||||
pub(crate) async fn remind(
|
||||
#[poise::command(slash_command, identifying_name = "remind")]
|
||||
pub async fn remind(
|
||||
ctx: Context<'_>,
|
||||
#[description = "A description of the time to set the reminder for"] time: String,
|
||||
#[description = "The message content to send"] content: String,
|
||||
|
@ -11,19 +11,29 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Manage todo lists
|
||||
#[poise::command(slash_command, rename = "todo")]
|
||||
#[poise::command(slash_command, rename = "todo", identifying_name = "todo_base")]
|
||||
pub async fn todo_base(_ctx: Context<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Manage the server todo list
|
||||
#[poise::command(slash_command, rename = "server", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "server",
|
||||
check = "guild_only",
|
||||
identifying_name = "todo_guild_base"
|
||||
)]
|
||||
pub async fn todo_guild_base(_ctx: Context<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add an item to the server todo list
|
||||
#[poise::command(slash_command, rename = "add")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "add",
|
||||
check = "guild_only",
|
||||
identifying_name = "todo_guild_add"
|
||||
)]
|
||||
pub async fn todo_guild_add(
|
||||
ctx: Context<'_>,
|
||||
#[description = "The task to add to the todo list"] task: String,
|
||||
@ -44,7 +54,12 @@ VALUES ((SELECT id FROM guilds WHERE guild = ?), ?)",
|
||||
}
|
||||
|
||||
/// View and remove from the server todo list
|
||||
#[poise::command(slash_command, rename = "view")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "view",
|
||||
check = "guild_only",
|
||||
identifying_name = "todo_guild_view"
|
||||
)]
|
||||
pub async fn todo_guild_view(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let values = sqlx::query!(
|
||||
"SELECT todos.id, value FROM todos
|
||||
@ -71,13 +86,23 @@ WHERE guilds.guild = ?",
|
||||
}
|
||||
|
||||
/// Manage the channel todo list
|
||||
#[poise::command(slash_command, rename = "channel", check = "guild_only")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "channel",
|
||||
check = "guild_only",
|
||||
identifying_name = "todo_channel_base"
|
||||
)]
|
||||
pub async fn todo_channel_base(_ctx: Context<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add an item to the channel todo list
|
||||
#[poise::command(slash_command, rename = "add")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "add",
|
||||
check = "guild_only",
|
||||
identifying_name = "todo_channel_add"
|
||||
)]
|
||||
pub async fn todo_channel_add(
|
||||
ctx: Context<'_>,
|
||||
#[description = "The task to add to the todo list"] task: String,
|
||||
@ -99,7 +124,12 @@ VALUES ((SELECT id FROM guilds WHERE guild = ?), (SELECT id FROM channels WHERE
|
||||
}
|
||||
|
||||
/// View and remove from the channel todo list
|
||||
#[poise::command(slash_command, rename = "view")]
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "view",
|
||||
check = "guild_only",
|
||||
identifying_name = "todo_channel_view"
|
||||
)]
|
||||
pub async fn todo_channel_view(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let values = sqlx::query!(
|
||||
"SELECT todos.id, value FROM todos
|
||||
@ -127,13 +157,13 @@ WHERE channels.channel = ?",
|
||||
}
|
||||
|
||||
/// Manage your personal todo list
|
||||
#[poise::command(slash_command, rename = "user")]
|
||||
#[poise::command(slash_command, rename = "user", identifying_name = "todo_user_base")]
|
||||
pub async fn todo_user_base(_ctx: Context<'_>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add an item to your personal todo list
|
||||
#[poise::command(slash_command, rename = "add")]
|
||||
#[poise::command(slash_command, rename = "add", identifying_name = "todo_user_add")]
|
||||
pub async fn todo_user_add(
|
||||
ctx: Context<'_>,
|
||||
#[description = "The task to add to the todo list"] task: String,
|
||||
@ -154,7 +184,7 @@ VALUES ((SELECT id FROM users WHERE user = ?), ?)",
|
||||
}
|
||||
|
||||
/// View and remove from your personal todo list
|
||||
#[poise::command(slash_command, rename = "view")]
|
||||
#[poise::command(slash_command, rename = "view", identifying_name = "todo_user_view")]
|
||||
pub async fn todo_user_view(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let values = sqlx::query!(
|
||||
"SELECT todos.id, value FROM todos
|
||||
|
Reference in New Issue
Block a user