2024-02-17 18:55:16 +00:00

37 lines
1.1 KiB
Rust

use log::warn;
use poise::CreateReply;
use crate::{models::CtxData, Context, Error};
/// 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) {
ctx.send(CreateReply::default().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 {
ctx.say("No webhook configured on this channel.").await?;
}
}
Err(e) => {
warn!("Error fetching channel data: {:?}", e);
ctx.say("No webhook configured on this channel.").await?;
}
}
Ok(())
}