chore: format
This commit is contained in:
@@ -26,21 +26,19 @@ pub static COMMAND: LazyLock<Command> = LazyLock::new(|| {
|
||||
.build()
|
||||
});
|
||||
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn handle(state: State, interaction: Interaction) {
|
||||
let revision = build_info::COMMIT_HASH;
|
||||
|
||||
let bot_owner_user_id = state.discord_bot_owner_user_id;
|
||||
|
||||
let is_bot_owner =
|
||||
interaction
|
||||
.member
|
||||
.as_ref()
|
||||
.and_then(|member| member.user.as_ref().map(|user| user.id))
|
||||
.map(|user_id| user_id == bot_owner_user_id)
|
||||
.unwrap_or(false);
|
||||
|
||||
let is_bot_owner = interaction
|
||||
.member
|
||||
.as_ref()
|
||||
.and_then(|member| member.user.as_ref().map(|user| user.id))
|
||||
.map(|user_id| user_id == bot_owner_user_id)
|
||||
.unwrap_or(false);
|
||||
|
||||
let bot_owner_mention = format!("<@{}>", bot_owner_user_id);
|
||||
|
||||
let opt_in_mention = format!(
|
||||
@@ -58,7 +56,7 @@ pub async fn handle(state: State, interaction: Interaction) {
|
||||
.create_response(
|
||||
interaction.id,
|
||||
&interaction.token,
|
||||
&InteractionResponse {
|
||||
&InteractionResponse {
|
||||
kind: InteractionResponseType::ChannelMessageWithSource,
|
||||
data: Some(
|
||||
InteractionResponseDataBuilder::new().embeds([
|
||||
@@ -87,7 +85,7 @@ pub async fn handle(state: State, interaction: Interaction) {
|
||||
})
|
||||
.await
|
||||
.expect("TODO");
|
||||
|
||||
|
||||
if is_bot_owner {
|
||||
let heat_script_description = state
|
||||
.bot_data_manager
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use clap::Parser;
|
||||
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 snafu::{OptionExt, ResultExt, Snafu};
|
||||
@@ -461,7 +462,9 @@ async fn handle_event(command_router: Arc<CommandRouter>, state: State, event: E
|
||||
|
||||
match event {
|
||||
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) => {
|
||||
let InteractionCreate(interaction) = *interaction_create;
|
||||
|
||||
@@ -15,7 +15,8 @@ use crate::{OneToManyUniqueBTreeMapWithData, OneToOneBTreeMap, UserInVCData, Voi
|
||||
pub type GuildVoiceChannelToTextChannel =
|
||||
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 VCsWatcher = watch::Sender<VCs>;
|
||||
|
||||
@@ -108,7 +109,9 @@ pub fn update_vcs(voice_state_update: &VoiceStateUpdate, vcs: &mut VCs) {
|
||||
.build();
|
||||
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!(
|
||||
?guild_id,
|
||||
|
||||
Reference in New Issue
Block a user