11use anyhow:: Context ;
22use serde:: Deserialize ;
33use twilight_model:: application:: command:: { CommandOptionChoice , CommandOptionChoiceValue } ;
4- use twilight_model:: channel :: message :: Embed ;
4+ use twilight_model:: http :: interaction :: InteractionResponseData ;
55use twilight_model:: id:: marker:: RoleMarker ;
66use twilight_model:: id:: Id ;
77
@@ -24,13 +24,16 @@ pub(crate) struct RoleConfig {
2424
2525/// Configuration for an option of the FAQ command.
2626#[ derive( Deserialize , Debug ) ]
27- struct FaqOption {
27+ pub ( crate ) struct FaqOption {
2828 /// The label of the option (displayed to the user).
2929 label : String ,
3030 /// The value of the option (used as the identifier).
3131 value : String ,
3232 /// The embed to be sent when this option is selected.
33- embed : Embed ,
33+ // pub(crate) embed: Embed,
34+ /// The components to be included with the embed.
35+ // pub(crate) components: Option<Vec<Component>>,
36+ pub ( crate ) response : InteractionResponseData ,
3437}
3538
3639impl Config {
@@ -46,22 +49,21 @@ impl Config {
4649 . collect ( )
4750 }
4851
49- /// Returns the embed associated with a given FAQ option value.
50- pub ( crate ) fn faq_option_embed < S > ( & self , value : S ) -> Option < Embed >
52+ /// Returns the FAQ option corresponding to the given value.
53+ pub ( crate ) fn faq_option_response < S > ( & self , value : S ) -> Option < InteractionResponseData >
5154 where
5255 S : AsRef < str > ,
5356 {
5457 self . faq_options
5558 . iter ( )
5659 . find ( |opt| opt. value == value. as_ref ( ) )
57- . map ( |opt| opt. embed . clone ( ) )
60+ . map ( |opt| opt. response . clone ( ) )
5861 }
5962}
6063
6164/// Loads the configuration from a YAML file.
62- #[ tracing:: instrument( ret) ]
63- pub ( crate ) fn load_config ( ) -> Result < Config , anyhow:: Error > {
64- let cfg_yaml = std:: fs:: read ( config_path ( ) ) . context ( "read config file" ) ?;
65+ pub ( crate ) fn load_config ( path : String ) -> Result < Config , anyhow:: Error > {
66+ let cfg_yaml = std:: fs:: read ( path) . context ( "read config file" ) ?;
6567 serde_yaml:: from_slice ( & cfg_yaml) . context ( "parse config file" )
6668}
6769
0 commit comments