use twilight_model::application::interaction::application_command::CommandData;
use twilight_model::gateway::payload::incoming::InteractionCreate;
use crate::commands::slash::SlashCommand;
use crate::handle::Handle;
use crate::state::StateBound;
use crate::wrappers::actions::interaction_respond::{
InteractionRespondWithDeferral, InteractionRespondWithMessage,
};
#[derive(Clone)]
pub struct SlashContext<State = ()>
where
State: StateBound,
{
pub state: State,
pub event: InteractionCreate,
pub event_data: CommandData,
pub handle: Handle<State>,
pub command: SlashCommand<State>,
}
impl<State> SlashContext<State>
where
State: StateBound,
{
pub fn respond(&self, content: impl Into<String>) -> InteractionRespondWithMessage {
InteractionRespondWithMessage::new(
self.handle.client.clone(),
self.event.application_id,
self.event.id,
self.event.token.clone(),
content,
)
}
pub fn defer(&self) -> InteractionRespondWithDeferral {
InteractionRespondWithDeferral::new(
self.handle.client.clone(),
self.event.application_id,
self.event.id,
self.event.token.clone(),
)
}
}