chore: format
This commit is contained in:
@@ -26,20 +26,18 @@ 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);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user