Extract trait
This commit is contained in:
@ -1,15 +1,19 @@
|
||||
use log::warn;
|
||||
use poise::CreateReply;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{models::CtxData, Context, Error};
|
||||
use crate::{models::CtxData, utils::Extract, ApplicationContext, 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> {
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Options;
|
||||
|
||||
impl Extract for Options {
|
||||
fn extract(_ctx: ApplicationContext) -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn webhook(ctx: Context<'_>, _options: Options) -> Result<(), Error> {
|
||||
match ctx.channel_data().await {
|
||||
Ok(data) => {
|
||||
if let (Some(id), Some(token)) = (data.webhook_id, data.webhook_token) {
|
||||
@ -34,3 +38,13 @@ Do not share it!
|
||||
|
||||
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 command(ctx: Context<'_>) -> Result<(), Error> {
|
||||
webhook(ctx, Options {}).await
|
||||
}
|
||||
|
Reference in New Issue
Block a user