feat: advertise opt in and opt out commands

This commit is contained in:
2026-04-22 12:11:36 -04:00
parent 9b479d1236
commit 2c0d5c8479
4 changed files with 399 additions and 364 deletions

View File

@@ -1,7 +1,7 @@
use clap::Parser;
use fomo_reducer::{
CommandRouter, GuildVoiceChannelToTextChannel, State, Storage, UserDataManager, all_commands,
initialize_vcs, update_vcs,
command, initialize_vcs, update_vcs,
};
use secrecy::{ExposeSecret, SecretString};
use snafu::{OptionExt, ResultExt, Snafu};
@@ -10,7 +10,7 @@ use songbird::{
driver::{Channels, DecodeConfig, SampleRate},
shards::TwilightMap,
};
use std::{fmt::Debug, str::FromStr, sync::Arc};
use std::{collections::BTreeMap, fmt::Debug, str::FromStr, sync::Arc};
use strum::EnumString;
use tokio::{select, signal::ctrl_c, task::JoinSet};
use tokio_util::{sync::CancellationToken, time::FutureExt as _};
@@ -275,7 +275,7 @@ async fn main() -> Result<(), MainError> {
let commands = all_commands();
let _returned_commands = interaction_client
let returned_commands = interaction_client
.set_global_commands(
Vec::from_iter(
commands
@@ -290,6 +290,25 @@ async fn main() -> Result<(), MainError> {
.await
.expect("failed to deserialize set commands"); // TODO
let mut discord_command_name_to_returned_command = BTreeMap::from_iter(
returned_commands
.into_iter()
.map(|command| (command.name.clone(), command)),
);
let discord_opt_in_command = discord_command_name_to_returned_command
.remove(&command::opt_in::COMMAND.name)
.expect("TODO");
let discord_opt_out_command = discord_command_name_to_returned_command
.remove(&command::opt_out::COMMAND.name)
.expect("TODO");
let discord_opt_in_command_id = discord_opt_in_command.id.expect("TODO");
let discord_opt_out_command_id = discord_opt_out_command.id.expect("TODO");
let discord_opt_in_command_name = discord_opt_in_command.name.into();
let discord_opt_out_command_name = discord_opt_out_command.name.into();
let vcs = initialize_vcs(&discord_client).await;
let command_router = CommandRouter::from_iter(commands);
@@ -329,6 +348,10 @@ async fn main() -> Result<(), MainError> {
discord_application_id,
discord_bot_owner_user_id,
discord_client,
discord_opt_in_command_id,
discord_opt_in_command_name,
discord_opt_out_command_id,
discord_opt_out_command_name,
discord_user_id,
discord_voice_channel_corresponding_text_channel,
recording_data,