feat: make VCsWatcher, a watch channel of VCs

This commit is contained in:
2026-05-06 19:49:08 -04:00
parent fa88bd495f
commit fcd856b61a
6 changed files with 51 additions and 83 deletions

View File

@@ -55,10 +55,10 @@ pub fn get_user_and_guild_and_voice_channel_id(
let guild_id = interaction.guild_id.context(NotInGuildSnafu)?;
let voice_channel_id = vcs
.with_guild(guild_id, |guild_vcs| {
guild_vcs.get_left_for(&bot_user_id).copied()
})
let &voice_channel_id = vcs
.get(&guild_id)
.context(BotNotInVCSnafu)?
.get_left_for(&bot_user_id)
.context(BotNotInVCSnafu)?;
Ok((user_id, guild_id, voice_channel_id))
@@ -80,11 +80,12 @@ fn get_guild_and_vc_error_to_embed(error: GetGuildAndVoiceChannelIdError) -> Emb
#[tracing::instrument]
pub async fn handle(state: State, interaction: Interaction) {
let (user_id, guild_id, voice_channel_id) = match get_user_and_guild_and_voice_channel_id(
let user_and_guild_and_voice_channel_id_res = get_user_and_guild_and_voice_channel_id(
state.discord_user_id,
&interaction,
&state.vcs,
) {
&state.vcs_watcher.borrow(),
);
let (user_id, guild_id, voice_channel_id) = match user_and_guild_and_voice_channel_id_res {
Ok((user_id, guild_id, voice_channel_id)) => (user_id, guild_id, voice_channel_id),
Err(error) => {
state