Webhook command

Add a command to view the webhook, as some users wish to use the webhook to edit past reminders.
This commit is contained in:
jude 2022-06-17 17:15:48 +01:00
parent 6f7d0f67b3
commit f56db14720
4 changed files with 36 additions and 2 deletions

2
Cargo.lock generated
View File

@ -2123,7 +2123,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "reminder_rs"
version = "1.6.0"
version = "1.6.1"
dependencies = [
"base64",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "reminder_rs"
version = "1.6.0"
version = "1.6.1"
authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018"

View File

@ -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<String> {
sqlx::query!(
"

View File

@ -101,6 +101,7 @@ async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> {
info_cmds::clock_context_menu(),
info_cmds::dashboard(),
moderation_cmds::timezone(),
moderation_cmds::webhook(),
poise::Command {
subcommands: vec![
moderation_cmds::delete_macro(),