feat: early steps of storage and configuration

This commit is contained in:
2026-04-09 22:39:02 -04:00
parent 7d3a309d2b
commit 7885526944
14 changed files with 393 additions and 54 deletions

View File

@@ -1,6 +1,9 @@
use crate::{VCs, command::State};
use async_trait::async_trait;
use snafu::{OptionExt, Snafu};
use std::sync::LazyLock;
use songbird::{CoreEvent, Event, EventContext, EventHandler};
use time::UtcDateTime;
use std::{sync::LazyLock, time::Instant};
use twilight_model::{
application::{
command::{Command, CommandType},
@@ -79,6 +82,45 @@ fn get_guild_and_vc_error_to_embed(error: GetGuildAndVoiceChannelIdError) -> Emb
}
}
#[derive(Debug, Clone)]
struct Handler {
start_instant: Instant,
start_utc: UtcDateTime,
}
#[async_trait]
impl EventHandler for Handler {
async fn act(&self, ctx: &EventContext<'_>) -> Option<Event> {
tracing::error!(?ctx, "TODO");
let Some(core_event) = ctx.to_core_event() else {
return None;
};
tracing::error!(?core_event, "TODO");
let elapsed = self.start_instant.elapsed();
let elapsed = elapsed.try_into().expect("TODO");
let now_utc = self.start_utc.checked_add(elapsed).expect("TODO");
tracing::error!(?now_utc, "TODO");
match core_event {
CoreEvent::SpeakingStateUpdate => todo!(),
CoreEvent::VoiceTick => todo!(),
CoreEvent::RtpPacket => todo!(),
CoreEvent::RtcpPacket => todo!(),
CoreEvent::ClientDisconnect => todo!(),
CoreEvent::DriverConnect => todo!(),
CoreEvent::DriverReconnect => todo!(),
CoreEvent::DriverDisconnect => todo!(),
_ => todo!(),
}
None
}
}
#[tracing::instrument(skip(state))]
pub async fn handle(state: State, interaction: Interaction) {
let vcs = state.vcs;
@@ -131,6 +173,15 @@ pub async fn handle(state: State, interaction: Interaction) {
tracing::error!(?call, "successfully joined");
let start_instant = Instant::now();
let start_utc = UtcDateTime::now();
let handler = Handler { start_instant, start_utc };
call.lock().await.add_global_event(
CoreEvent::RtpPacket.into(),
handler,
);
let channel_mention = format!("<#{voice_channel_id}>");
state