feat: make VCsWatcher, a watch channel of VCs
This commit is contained in:
@@ -67,10 +67,10 @@ fn get_guild_and_voice_channel_id(
|
||||
.and_then(|member| member.user.as_ref().map(|user| user.id))
|
||||
.context(NoUserSnafu)?;
|
||||
|
||||
let voice_channel_id = vcs
|
||||
.with_guild(guild_id, |guild_vcs| {
|
||||
guild_vcs.get_left_for(&user_id).copied()
|
||||
})
|
||||
let &voice_channel_id = vcs
|
||||
.get(&guild_id)
|
||||
.context(UserNotInVCSnafu)?
|
||||
.get_left_for(&user_id)
|
||||
.context(UserNotInVCSnafu)?;
|
||||
|
||||
Ok((guild_id, voice_channel_id))
|
||||
@@ -236,33 +236,33 @@ impl EventHandler for Handler {
|
||||
|
||||
#[tracing::instrument(skip(state))]
|
||||
pub async fn handle(state: State, interaction: Interaction) {
|
||||
let vcs = state.vcs;
|
||||
let guild_and_voice_channel_id_res = get_guild_and_voice_channel_id(&interaction, &state.vcs_watcher.borrow());
|
||||
let (guild_id, voice_channel_id) =
|
||||
match guild_and_voice_channel_id_res {
|
||||
Ok((guild_id, voice_channel_id)) => (guild_id, voice_channel_id),
|
||||
Err(error) => {
|
||||
state
|
||||
.discord_client
|
||||
.interaction(state.discord_application_id)
|
||||
.create_response(
|
||||
interaction.id,
|
||||
&interaction.token,
|
||||
&InteractionResponse {
|
||||
kind: InteractionResponseType::ChannelMessageWithSource,
|
||||
data: Some(
|
||||
InteractionResponseDataBuilder::new()
|
||||
.embeds([get_guild_and_vc_error_to_embed(error)])
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
.build(),
|
||||
),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("TODO");
|
||||
|
||||
let (guild_id, voice_channel_id) = match get_guild_and_voice_channel_id(&interaction, &vcs) {
|
||||
Ok((guild_id, voice_channel_id)) => (guild_id, voice_channel_id),
|
||||
Err(error) => {
|
||||
state
|
||||
.discord_client
|
||||
.interaction(state.discord_application_id)
|
||||
.create_response(
|
||||
interaction.id,
|
||||
&interaction.token,
|
||||
&InteractionResponse {
|
||||
kind: InteractionResponseType::ChannelMessageWithSource,
|
||||
data: Some(
|
||||
InteractionResponseDataBuilder::new()
|
||||
.embeds([get_guild_and_vc_error_to_embed(error)])
|
||||
.flags(MessageFlags::EPHEMERAL)
|
||||
.build(),
|
||||
),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("TODO");
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
state
|
||||
.discord_client
|
||||
|
||||
Reference in New Issue
Block a user