From 05a57be964942ad3a6a275c7aad819f652a738a2 Mon Sep 17 00:00:00 2001 From: shibedrill <53824200+shibedrill@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:54:49 -0400 Subject: [PATCH] edit perms, add say --- src/command/devel.rs | 14 ++++++++++++++ src/command/fun.rs | 3 ++- src/command/util.rs | 6 +++--- src/main.rs | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/command/devel.rs b/src/command/devel.rs index 9b99a09..ec6205f 100644 --- a/src/command/devel.rs +++ b/src/command/devel.rs @@ -22,3 +22,17 @@ pub async fn restart(ctx: Context<'_>) -> Result<(), Error> { info!("Executed command `restart` successfully"); Ok(()) } + +/// Say a specific message +#[poise::command(slash_command, owners_only, hide_in_help)] +pub async fn say( + ctx: Context<'_>, + #[description = "The message content to send"] what: String, + #[description = "Whether to make it ephemeral"] ephemeral: Option, +) -> Result<(), Error> { + if ephemeral == Some(true) { + ctx.defer_ephemeral().await?; + } + ctx.say(what).await?; + Ok(()) +} diff --git a/src/command/fun.rs b/src/command/fun.rs index 6a7ea9c..729e3fb 100644 --- a/src/command/fun.rs +++ b/src/command/fun.rs @@ -111,7 +111,8 @@ pub async fn deer(ctx: Context<'_>) -> Result<(), Error> { let mut rng = rand::thread_rng(); hot.data.children.choose(&mut rng).unwrap() }; - ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink)).await?; + ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink)) + .await?; info!("Executed command `deer` successfully"); Ok(()) } diff --git a/src/command/util.rs b/src/command/util.rs index c7e5abe..928eb5e 100644 --- a/src/command/util.rs +++ b/src/command/util.rs @@ -51,7 +51,7 @@ pub async fn info(ctx: Context<'_>) -> Result<(), Error> { } /// Add channel to the registry -#[poise::command(slash_command)] +#[poise::command(slash_command, required_permissions = "MANAGE_CHANNELS")] pub async fn add_channel( ctx: Context<'_>, #[description = "Selected channel"] channel: serenity::Channel, @@ -70,7 +70,7 @@ pub async fn add_channel( } /// Remove channel from the registry -#[poise::command(slash_command)] +#[poise::command(slash_command, required_permissions = "MANAGE_CHANNELS")] pub async fn remove_channel( ctx: Context<'_>, #[description = "Selected channel"] channel: serenity::Channel, @@ -90,7 +90,7 @@ pub async fn remove_channel( } /// List channels held in the registry -#[poise::command(slash_command)] +#[poise::command(slash_command, required_permissions = "MANAGE_CHANNELS")] pub async fn list_channels(ctx: Context<'_>) -> Result<(), Error> { ctx.defer_ephemeral().await?; let config = &mut ctx.data().config_manager.lock().await; diff --git a/src/main.rs b/src/main.rs index b3573a8..eccaf01 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,6 +88,7 @@ async fn main() { // Dev shutdown(), restart(), + say(), // Fun meow(), whack(),