Skip to content

Commit

Permalink
reset select menu after interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinfuchs committed Aug 7, 2022
1 parent 57f5f5b commit 72d8269
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions backend/src/bot/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,26 @@ async fn handle_unknown_component(
response.replace_variables(&variables);
simple_response(&http, interaction.id, &interaction.token, response).await?;
} else {
handle_component_actions(http, interaction, comp, actions).await?;
handle_component_actions(&http, &interaction, actions).await?;
}

if comp.component_type == ComponentType::SelectMenu {
// we reset the menu to the initial state
// TODO: it would be better if this was performed before the actions
let _ = http
.update_followup(&interaction.token, message.id)
.components(Some(&message.components))
.unwrap()
.exec()
.await;
}

Ok(())
}

async fn handle_component_actions(
http: InteractionClient<'_>,
interaction: Interaction,
_comp: MessageComponentInteractionData,
http: &InteractionClient<'_>,
interaction: &Interaction,
actions: Vec<MessageAction>,
) -> InteractionResult {
for action in actions {
Expand Down

0 comments on commit 72d8269

Please sign in to comment.