fn on_msg_interaction(&self, mut msg: MessageComponentInteraction) -> error::Result<InteractionResponse> {
        use twilight_model::{application::component::ComponentType::SelectMenu, user::User};
        if !matches!(msg.data.component_type, SelectMenu) {
            return Err(error::Error::UnsupportedInteraction);
        }

        let User { id, .. } = msg.member.and_then(|m| m.user).or(msg.user).ok_or(error::Error::UnknownUser)?;

        // Since we know that there can only be one value from this interaction,
        // we simply pop the arguments directly. This allows O(1) deletion.
        let arg = msg.data.values.pop().ok_or(error::Error::Unrecoverable)?;
        let choice = arg.parse().map_err(|_| error::Error::InvalidParams)?;
        drop(arg);

        let quiz_id = msg.data.custom_id.parse().map_err(|_| error::Error::Unrecoverable)?;
        self.inner
            .quizzes
            .get(&quiz_id)
            .ok_or(error::Error::UnknownQuiz)?
            .send((id, choice))
            .map_err(|_| error::Error::Unrecoverable)?;

        Ok(InteractionResponse {
            kind: InteractionResponseType::ChannelMessageWithSource,
            data: Some(InteractionResponseData {
                content: Some(String::from("We have received your selection.")),
                flags: Some(MessageFlags::EPHEMERAL),
                components: None,
                tts: None,
                allowed_mentions: None,
                embeds: None,
                attachments: None,
                choices: None,
                custom_id: None,
                title: None,
            }),
        })
    }
/// Responds to message component interactions.

Responds to message component interactions.
Responds to message component interactions .
fn on_msg_interaction(&self, mut msg: MessageComponentInteraction) -> error::Result<InteractionResponse> {
        use twilight_model::{application::component::ComponentType::SelectMenu, user::User};
        if !matches!(msg.data.component_type, SelectMenu) {
            return Err(error::Error::UnsupportedInteraction);
        }
        let User { id, .. } = msg.member.and_then(|m| m.user).or(msg.user).ok_or(error::Error::UnknownUser)?;
        // Since we know that there can only be one value from this interaction,
        // we simply pop the arguments directly. This allows O(1) deletion.
        let arg = msg.data.values.pop().ok_or(error::Error::Unrecoverable)?;
        let choice = arg.parse().map_err(|_| error::Error::InvalidParams)?;
        drop(arg);
        let quiz_id = msg.data.custom_id.parse().map_err(|_| error::Error::Unrecoverable)?;
        self.inner
            .quizzes
            .get(&quiz_id)
            .ok_or(error::Error::UnknownQuiz)?
            .send((id, choice))
            .map_err(|_| error::Error::Unrecoverable)?;
        Ok(InteractionResponse {
            kind: InteractionResponseType::ChannelMessageWithSource,
            data: Some(InteractionResponseData {
                content: Some(String::from("We have received your selection.")),
                flags: Some(MessageFlags::EPHEMERAL),
                components: None,
                tts: None,
                allowed_mentions: None,
                embeds: None,
                attachments: None,
                choices: None,
                custom_id: None,
                title: None,
            }),
        })
    }
fn on_msg_interaction ( & self , mut msg : MessageComponentInteraction ) -> error :: Result < InteractionResponse > { use twilight_model :: { application :: component :: ComponentType :: SelectMenu , user :: User } ; if ! matches ! ( msg data component_type SelectMenu ) { return Err ( error :: Error :: UnsupportedInteraction ) ; } let User { id , .. } = msg . member . and_then ( | m | m . user ) . or ( msg . user ) . ok_or ( error :: Error :: UnknownUser ) ? ; // Since we know that there can only be one value from this interaction,
 // we simply pop the arguments directly. This allows O(1) deletion.
 let arg = msg . data . values . pop ( ) . ok_or ( error :: Error :: Unrecoverable ) ? ; let choice = arg . parse ( ) . map_err ( | _ | error :: Error :: InvalidParams ) ? ; drop ( arg ) ; let quiz_id = msg . data . custom_id . parse ( ) . map_err ( | _ | error :: Error :: Unrecoverable ) ? ; self . inner . quizzes . get ( & quiz_id ) . ok_or ( error :: Error :: UnknownQuiz ) ? . send ( ( id , choice ) ) . map_err ( | _ | error :: Error :: Unrecoverable ) ? ; Ok ( InteractionResponse { kind : InteractionResponseType :: ChannelMessageWithSource , data : Some ( InteractionResponseData { content : Some ( String :: from ( " " ) ) , flags : Some ( MessageFlags :: EPHEMERAL ) , components : None , tts : None , allowed_mentions : None , embeds : None , attachments : None , choices : None , custom_id : None , title : None , } ) , } ) }
Responds to message component interactions.
Responds to message component interactions .
&self
msg
MessageComponentInteraction
&self
msg
MessageComponentInteraction