feat: set the global commands
This commit is contained in:
@@ -9,5 +9,6 @@ pub use one_to_many::OneToManyUniqueBTreeMap;
|
|||||||
pub use one_to_many_with_data::OneToManyUniqueBTreeMapWithData;
|
pub use one_to_many_with_data::OneToManyUniqueBTreeMapWithData;
|
||||||
pub use one_to_one::OneToOneBTreeMap;
|
pub use one_to_one::OneToOneBTreeMap;
|
||||||
|
|
||||||
|
pub use command::all as all_commands;
|
||||||
pub use track_vcs::{VCs, initialize_vcs, update_vcs};
|
pub use track_vcs::{VCs, initialize_vcs, update_vcs};
|
||||||
pub use vc_user::{UserInVCData, VoiceStatus};
|
pub use vc_user::{UserInVCData, VoiceStatus};
|
||||||
|
|||||||
34
src/main.rs
34
src/main.rs
@@ -1,5 +1,5 @@
|
|||||||
use clap::Parser;
|
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 opendal::{IntoOperatorUri, Operator, OperatorUri};
|
||||||
use secrecy::{ExposeSecret, SecretString};
|
use secrecy::{ExposeSecret, SecretString};
|
||||||
use snafu::Snafu;
|
use snafu::Snafu;
|
||||||
@@ -109,6 +109,38 @@ async fn main() -> Result<(), MainError> {
|
|||||||
let mut next_event = shard.next_event(vc_event_types);
|
let mut next_event = shard.next_event(vc_event_types);
|
||||||
|
|
||||||
let discord_client = twilight_http::Client::new(discord_token.expose_secret().to_owned());
|
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;
|
let mut voice_status = initialize_vcs(&discord_client).await;
|
||||||
while let Some(event_res) = next_event.await {
|
while let Some(event_res) = next_event.await {
|
||||||
match event_res {
|
match event_res {
|
||||||
|
|||||||
Reference in New Issue
Block a user