stat_summoner/
interactions.rs

1use crate::models::data::Data;
2use crate::models::error::Error;
3use crate::module::askingforflex::interaction_flex_buttons::handle_interaction_button_flex;
4/// Handles the interaction button black list.
5///
6/// This function processes interactions related to the black list of buttons.
7/// It is used to manage and handle the logic when a button that is blacklisted
8/// is interacted with.
9///
10/// # Arguments
11///
12/// * `interaction` - The interaction object that contains details about the interaction event.
13///
14/// # Returns
15///
16/// This function does not return a value.
17///
18/// # Examples
19///
20/// ```rust
21/// use crate::module::suggestions::interaction_black_list::handle_interaction_button_black_list;
22///
23/// // Example usage
24/// handle_interaction_button_black_list(interaction);
25/// ```
26///
27/// # Errors
28///
29/// This function does not return errors directly, but it may cause side effects
30/// or trigger other error-handling mechanisms within the application.
31use crate::module::suggestions::interaction_black_list::handle_interaction_button_black_list;
32use poise::serenity_prelude::Interaction;
33
34pub async fn handle_button_click(
35    ctx: poise::serenity_prelude::Context,
36    interaction: Interaction,
37    ctx_data: &Data,
38) -> Result<(), Error> {
39    if let Some(message_component_interaction) = interaction.message_component() {
40        let http = ctx.http.clone();
41        message_component_interaction.defer(http).await?;
42        let custom_id = &message_component_interaction.data.custom_id;
43
44        if custom_id.starts_with("blacklist_user:") {
45            handle_interaction_button_black_list(ctx, message_component_interaction, ctx_data)
46                .await?;
47        } else if custom_id.starts_with("flex_user:") {
48            handle_interaction_button_flex(ctx, message_component_interaction, ctx_data).await?;
49        }
50    }
51    Ok(())
52}