Override default manifold handlers for message edits and deletions
This commit is contained in:
parent
0c326fc89e
commit
e20a327db1
|
|
@ -1405,8 +1405,8 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
|||
|
||||
[[package]]
|
||||
name = "manifold"
|
||||
version = "6.1.1"
|
||||
source = "git+https://code.orbiter-radio.uk/discord/manifold.git#04cd52f7e494ab905ab9d9d03daeb3efe77ab392"
|
||||
version = "7.0.0"
|
||||
source = "git+https://code.orbiter-radio.uk/discord/manifold.git#8602c883d3d3146b0ec8258f4986d33203e5e92a"
|
||||
dependencies = [
|
||||
"built",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "hal"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
edition = "2024"
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ enum ReminderCadence {
|
|||
}
|
||||
|
||||
#[poise::command(slash_command, prefix_command, aliases("r"))]
|
||||
async fn reminder(ctx: ManifoldContext<'_>, target: RoleId, cadence: ReminderCadence, tod: u8) -> ManifoldResult<()> {
|
||||
async fn reminder(_ctx: ManifoldContext<'_>, _target: RoleId, _cadence: ReminderCadence, _tod: u8) -> ManifoldResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use manifold::error::{ManifoldError, ManifoldResult};
|
||||
use manifold::events::{EventHandler, Handler};
|
||||
use manifold::events::EventHandler;
|
||||
use manifold::ManifoldData;
|
||||
use poise::{async_trait, FrameworkContext, Event};
|
||||
use poise::serenity_prelude::{Context, Ready};
|
||||
use poise::{async_trait, Event, FrameworkContext};
|
||||
|
||||
pub struct HalHandler {
|
||||
|
||||
|
|
@ -10,19 +10,31 @@ pub struct HalHandler {
|
|||
|
||||
#[async_trait]
|
||||
impl EventHandler for HalHandler {
|
||||
async fn listen(ctx: &Context, framework_ctx: FrameworkContext<'_, ManifoldData, ManifoldError>, event: &Event<'_>) -> ManifoldResult<()> {
|
||||
async fn listen(ctx: &Context, framework_ctx: FrameworkContext<'_, ManifoldData, ManifoldError>, event: &Event<'_>) -> ManifoldResult<bool> {
|
||||
match event {
|
||||
Event::Ready { data_about_bot } => Handler::standard_startup(&ctx, &framework_ctx, data_about_bot).await,
|
||||
_ => Ok(())
|
||||
Event::MessageDelete { channel_id: _channel_id, deleted_message_id: _deleted_message_id, guild_id: _guild_id } => HalHandler::message_deleted().await,
|
||||
Event::MessageUpdate { old_if_available: _old_if_available, new: _new, event: _event } => HalHandler::message_edited().await,
|
||||
Event::Ready { data_about_bot } => HalHandler::standard_startup(&ctx, &framework_ctx, data_about_bot).await,
|
||||
_ => Ok(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HalHandler {
|
||||
|
||||
pub async fn standard_startup(ctx: &Context, framework_ctx: &FrameworkContext<'_, ManifoldData, ManifoldError>, data_about_bot: &Ready) -> ManifoldResult<()> {
|
||||
|
||||
Ok(())
|
||||
async fn standard_startup(_ctx: &Context, _framework_ctx: &FrameworkContext<'_, ManifoldData, ManifoldError>, _data_about_bot: &Ready) -> ManifoldResult<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
async fn message_deleted() -> ManifoldResult<bool> {
|
||||
// Return true here to override the default manifold handler
|
||||
debug!("Default manifold handler overridden");
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
async fn message_edited() -> ManifoldResult<bool> {
|
||||
// Return true here to override the default manifold handler
|
||||
debug!("Default manifold handler overridden");
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue