tulpje-framework 0.17.0

Multi-purpose discord bot & framework
Documentation
use std::sync::Arc;

use twilight_http::{Client, client::InteractionClient};
use twilight_model::id::{Id, marker::ApplicationMarker};
use twilight_standby::Standby;

pub mod autocomplete_context;
pub mod command_context;
pub mod component_interaction_context;
pub mod event_context;
pub mod modal_context;
pub mod task_context;

pub use command_context::CommandContext;
pub use component_interaction_context::ComponentInteractionContext;
pub use event_context::EventContext;
pub use modal_context::ModalContext;
pub use task_context::TaskContext;

#[derive(Debug)]
pub struct Context<T: Clone + Send + Sync> {
    pub application_id: Id<ApplicationMarker>,
    pub services: Arc<T>,
    pub client: Arc<Client>,
    pub standby: Arc<Standby>,
}

impl<T: Clone + Send + Sync> Context<T> {
    pub fn interaction(&self) -> InteractionClient<'_> {
        self.client.interaction(self.application_id)
    }
}

impl<T: Clone + Send + Sync> Clone for Context<T> {
    fn clone(&self) -> Self {
        Self {
            application_id: self.application_id,
            services: Arc::clone(&self.services),
            client: Arc::clone(&self.client),
            standby: Arc::clone(&self.standby),
        }
    }
}

pub enum InteractionContext<T: Clone + Send + Sync> {
    Command(CommandContext<T>),
    ComponentInteraction(ComponentInteractionContext<T>),
    Modal(ModalContext<T>),
}