From 67bdc9e451bd673d734cc4589ac0816130ec340a Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 24 Mar 2026 01:59:57 -0400 Subject: [PATCH] feat: set the global commands --- src/lib.rs | 1 + src/main.rs | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 09432eb..dd01016 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,5 +9,6 @@ pub use one_to_many::OneToManyUniqueBTreeMap; pub use one_to_many_with_data::OneToManyUniqueBTreeMapWithData; pub use one_to_one::OneToOneBTreeMap; +pub use command::all as all_commands; pub use track_vcs::{VCs, initialize_vcs, update_vcs}; pub use vc_user::{UserInVCData, VoiceStatus}; diff --git a/src/main.rs b/src/main.rs index 6e8480e..ed80a80 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use clap::Parser; -use fomo_reducer::{VCs, initialize_vcs, update_vcs}; +use fomo_reducer::{VCs, all_commands, initialize_vcs, update_vcs}; use opendal::{IntoOperatorUri, Operator, OperatorUri}; use secrecy::{ExposeSecret, SecretString}; use snafu::Snafu; @@ -109,6 +109,38 @@ async fn main() -> Result<(), MainError> { let mut next_event = shard.next_event(vc_event_types); let discord_client = twilight_http::Client::new(discord_token.expose_secret().to_owned()); + + let current_application = discord_client + .current_user_application() + .await + .expect("couldn't get current Discord application"); // TODO + + let current_application = current_application + .model() + .await + .expect("couldn't get current Discord application"); // TODO + + let application_id = current_application.id; + + let interaction_client = discord_client.interaction(application_id); + + let commands = all_commands(); + + let returned_commands = interaction_client + .set_global_commands( + Vec::from_iter( + commands + .iter() + .map(|(command, _handler)| (*command).clone()), + ) + .as_slice(), + ) + .await + .expect("failed to set interaction commands") // TODO + .models() + .await + .expect("failed to deserialize set commands"); // TODO + let mut voice_status = initialize_vcs(&discord_client).await; while let Some(event_res) = next_event.await { match event_res {