mirror of
https://github.com/mii443/rs-docker-bot.git
synced 2025-08-23 00:25:30 +00:00
add poise event handler
This commit is contained in:
@ -9,7 +9,28 @@ use log::info;
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use tokio::time::{sleep_until, Instant};
|
use tokio::time::{sleep_until, Instant};
|
||||||
|
|
||||||
use crate::docker::{docker_ps, Container};
|
use crate::{
|
||||||
|
docker::{docker_ps, Container},
|
||||||
|
Data, Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
use poise::serenity_prelude as serenity;
|
||||||
|
|
||||||
|
pub async fn event_handler(
|
||||||
|
ctx: &serenity::Context,
|
||||||
|
event: &serenity::FullEvent,
|
||||||
|
_framework: poise::FrameworkContext<'_, Data, Error>,
|
||||||
|
data: &Data,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
match event {
|
||||||
|
serenity::FullEvent::Ready { .. } => {
|
||||||
|
println!("bot ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Handler;
|
pub struct Handler;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use std::{collections::HashSet, env, fs::File, io::Read, sync::Arc};
|
|||||||
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
||||||
|
use event_handler::event_handler;
|
||||||
use poise::{
|
use poise::{
|
||||||
serenity_prelude::{self as serenity, futures::lock::Mutex, UserId},
|
serenity_prelude::{self as serenity, futures::lock::Mutex, UserId},
|
||||||
PrefixFrameworkOptions,
|
PrefixFrameworkOptions,
|
||||||
@ -54,6 +55,9 @@ async fn main() -> Result<(), ()> {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.options(poise::FrameworkOptions {
|
.options(poise::FrameworkOptions {
|
||||||
|
event_handler: |ctx, event, framework, data| {
|
||||||
|
Box::pin(event_handler(ctx, event, framework, data))
|
||||||
|
},
|
||||||
commands: vec![],
|
commands: vec![],
|
||||||
prefix_options: PrefixFrameworkOptions {
|
prefix_options: PrefixFrameworkOptions {
|
||||||
prefix: Some(config.prefix),
|
prefix: Some(config.prefix),
|
||||||
|
Reference in New Issue
Block a user