chore: format

This commit is contained in:
2026-05-06 21:40:14 -04:00
parent 44c7aa60c2
commit 2dbc0a2e87
3 changed files with 19 additions and 15 deletions

View File

@@ -26,21 +26,19 @@ pub static COMMAND: LazyLock<Command> = LazyLock::new(|| {
.build() .build()
}); });
#[tracing::instrument] #[tracing::instrument]
pub async fn handle(state: State, interaction: Interaction) { pub async fn handle(state: State, interaction: Interaction) {
let revision = build_info::COMMIT_HASH; let revision = build_info::COMMIT_HASH;
let bot_owner_user_id = state.discord_bot_owner_user_id; let bot_owner_user_id = state.discord_bot_owner_user_id;
let is_bot_owner = let is_bot_owner = interaction
interaction .member
.member .as_ref()
.as_ref() .and_then(|member| member.user.as_ref().map(|user| user.id))
.and_then(|member| member.user.as_ref().map(|user| user.id)) .map(|user_id| user_id == bot_owner_user_id)
.map(|user_id| user_id == bot_owner_user_id) .unwrap_or(false);
.unwrap_or(false);
let bot_owner_mention = format!("<@{}>", bot_owner_user_id); let bot_owner_mention = format!("<@{}>", bot_owner_user_id);
let opt_in_mention = format!( let opt_in_mention = format!(
@@ -58,7 +56,7 @@ pub async fn handle(state: State, interaction: Interaction) {
.create_response( .create_response(
interaction.id, interaction.id,
&interaction.token, &interaction.token,
&InteractionResponse { &InteractionResponse {
kind: InteractionResponseType::ChannelMessageWithSource, kind: InteractionResponseType::ChannelMessageWithSource,
data: Some( data: Some(
InteractionResponseDataBuilder::new().embeds([ InteractionResponseDataBuilder::new().embeds([
@@ -87,7 +85,7 @@ pub async fn handle(state: State, interaction: Interaction) {
}) })
.await .await
.expect("TODO"); .expect("TODO");
if is_bot_owner { if is_bot_owner {
let heat_script_description = state let heat_script_description = state
.bot_data_manager .bot_data_manager

View File

@@ -1,6 +1,7 @@
use clap::Parser; use clap::Parser;
use fomo_reducer::{ use fomo_reducer::{
BotDataManager, CommandRouter, GuildVoiceChannelToTextChannel, State, Storage, UserDataManager, VCsWatcher, all_commands, command, initialize_vcs, update_vcs BotDataManager, CommandRouter, GuildVoiceChannelToTextChannel, State, Storage, UserDataManager,
VCsWatcher, all_commands, command, initialize_vcs, update_vcs,
}; };
use secrecy::{ExposeSecret, SecretString}; use secrecy::{ExposeSecret, SecretString};
use snafu::{OptionExt, ResultExt, Snafu}; use snafu::{OptionExt, ResultExt, Snafu};
@@ -461,7 +462,9 @@ async fn handle_event(command_router: Arc<CommandRouter>, state: State, event: E
match event { match event {
Event::VoiceStateUpdate(voice_state_update) => { Event::VoiceStateUpdate(voice_state_update) => {
state.vcs_watcher.send_modify(|vcs| update_vcs(&voice_state_update, vcs)); state
.vcs_watcher
.send_modify(|vcs| update_vcs(&voice_state_update, vcs));
} }
Event::InteractionCreate(interaction_create) => { Event::InteractionCreate(interaction_create) => {
let InteractionCreate(interaction) = *interaction_create; let InteractionCreate(interaction) = *interaction_create;

View File

@@ -15,7 +15,8 @@ use crate::{OneToManyUniqueBTreeMapWithData, OneToOneBTreeMap, UserInVCData, Voi
pub type GuildVoiceChannelToTextChannel = pub type GuildVoiceChannelToTextChannel =
BTreeMap<Id<GuildMarker>, OneToOneBTreeMap<Id<ChannelMarker>, Id<ChannelMarker>>>; BTreeMap<Id<GuildMarker>, OneToOneBTreeMap<Id<ChannelMarker>, Id<ChannelMarker>>>;
pub type VCsInGuild = OneToManyUniqueBTreeMapWithData<Id<ChannelMarker>, Id<UserMarker>, UserInVCData>; pub type VCsInGuild =
OneToManyUniqueBTreeMapWithData<Id<ChannelMarker>, Id<UserMarker>, UserInVCData>;
pub type VCs = BTreeMap<Id<GuildMarker>, VCsInGuild>; pub type VCs = BTreeMap<Id<GuildMarker>, VCsInGuild>;
pub type VCsWatcher = watch::Sender<VCs>; pub type VCsWatcher = watch::Sender<VCs>;
@@ -108,7 +109,9 @@ pub fn update_vcs(voice_state_update: &VoiceStateUpdate, vcs: &mut VCs) {
.build(); .build();
let user_in_vc_data = voice_status.into(); let user_in_vc_data = voice_status.into();
vcs.entry(guild_id).or_default().insert(channel_id, user_id, user_in_vc_data); vcs.entry(guild_id)
.or_default()
.insert(channel_id, user_id, user_in_vc_data);
tracing::info!( tracing::info!(
?guild_id, ?guild_id,