diff --git a/Cargo.lock b/Cargo.lock index 116ee5b..be44253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2123,7 +2123,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "reminder_rs" -version = "1.6.0" +version = "1.6.1" dependencies = [ "base64", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 44a5026..1a07122 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reminder_rs" -version = "1.6.0" +version = "1.6.1" authors = ["jellywx "] edition = "2018" diff --git a/src/commands/moderation_cmds.rs b/src/commands/moderation_cmds.rs index 4fc325f..e1eb48a 100644 --- a/src/commands/moderation_cmds.rs +++ b/src/commands/moderation_cmds.rs @@ -124,6 +124,39 @@ You may want to use one of the popular timezones below, otherwise click [here](h Ok(()) } +/// View the webhook being used to send reminders to this channel +#[poise::command( + slash_command, + identifying_name = "webhook_url", + required_permissions = "ADMINISTRATOR" +)] +pub async fn webhook(ctx: Context<'_>) -> Result<(), Error> { + match ctx.channel_data().await { + Ok(data) => { + if let (Some(id), Some(token)) = (data.webhook_id, data.webhook_token) { + let _ = ctx + .send(|b| { + b.ephemeral(true).content(format!( + "**Warning!** +This link can be used by users to anonymously send messages, with or without permissions. +Do not share it! +|| https://discord.com/api/webhooks/{}/{} ||", + id, token, + )) + }) + .await; + } else { + let _ = ctx.say("No webhook configured on this channel.").await; + } + } + Err(_) => { + let _ = ctx.say("No webhook configured on this channel.").await; + } + } + + Ok(()) +} + async fn macro_name_autocomplete(ctx: Context<'_>, partial: String) -> Vec { sqlx::query!( " diff --git a/src/main.rs b/src/main.rs index ae77c17..6a9d9bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,6 +101,7 @@ async fn _main(tx: Sender<()>) -> Result<(), Box> { info_cmds::clock_context_menu(), info_cmds::dashboard(), moderation_cmds::timezone(), + moderation_cmds::webhook(), poise::Command { subcommands: vec![ moderation_cmds::delete_macro(),