osu: Implement check button!

This commit is contained in:
Natsu Kagami 2024-07-14 00:16:12 +02:00
parent 1d250b8ea7
commit 32053c3fe3
Signed by: nki
GPG key ID: 55A032EB38B49ADB
11 changed files with 274 additions and 75 deletions

View file

@ -1,5 +1,5 @@
use crate::{async_trait, future, Context, Result};
use serenity::model::channel::Message;
use serenity::{all::Interaction, model::channel::Message};
/// Hook represents the asynchronous hook that is run on every message.
#[async_trait]
@ -22,3 +22,25 @@ where
self(ctx, message).await
}
}
/// InteractionHook represents the asynchronous hook that is run on every interaction.
#[async_trait]
pub trait InteractionHook: Send + Sync {
async fn call(&mut self, ctx: &Context, interaction: &Interaction) -> Result<()>;
}
#[async_trait]
impl<T> InteractionHook for T
where
T: for<'a> FnMut(
&'a Context,
&'a Interaction,
)
-> std::pin::Pin<Box<dyn future::Future<Output = Result<()>> + 'a + Send>>
+ Send
+ Sync,
{
async fn call(&mut self, ctx: &Context, interaction: &Interaction) -> Result<()> {
self(ctx, interaction).await
}
}

View file

@ -164,7 +164,8 @@ pub async fn paginate(
paginate_with_first_message(pager, ctx, message, timeout).await
}
async fn paginate_with_first_message(
/// Paginate with the first message already created.
pub async fn paginate_with_first_message(
mut pager: impl Paginate,
ctx: &Context,
mut message: Message,