mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-25 09:40:49 +00:00
osu: Implement check button!
This commit is contained in:
parent
1d250b8ea7
commit
32053c3fe3
11 changed files with 274 additions and 75 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue