File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ pub struct Config {
1212 pub redis : RedisConfig ,
1313 #[ serde( default ) ]
1414 pub amqp : AmqpConfig ,
15+ #[ serde( default ) ]
16+ pub discord : DiscordConfig ,
1517 #[ serde( default , deserialize_with = "deserialize_duration" ) ]
1618 pub timeout : Option < Duration > ,
1719}
@@ -56,6 +58,7 @@ impl Config {
5658 "AMQP_EVENT" => self . amqp . event = v,
5759 "AMQP_CANCELLATION_EVENT" => self . amqp . cancellation_event = v,
5860 "TIMEOUT" => self . timeout = v. parse ( ) . ok ( ) ,
61+ "DISCORD_API_VERSION" => self . discord . api_version = v. parse ( ) . expect ( "valid DISCORD_API_VERSION (u8)" ) ,
5962 _ => { }
6063 }
6164 }
@@ -127,3 +130,23 @@ impl Default for AmqpConfig {
127130 }
128131 }
129132}
133+
134+ #[ derive( Debug , Deserialize ) ]
135+ pub struct DiscordConfig {
136+ #[ serde( default = "DiscordConfig::default_api_version" ) ]
137+ pub api_version : u8 ,
138+ }
139+
140+ impl DiscordConfig {
141+ fn default_api_version ( ) -> u8 {
142+ return 6 ;
143+ }
144+ }
145+
146+ impl Default for DiscordConfig {
147+ fn default ( ) -> Self {
148+ Self {
149+ api_version : Self :: default_api_version ( ) ,
150+ }
151+ }
152+ }
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ async fn main() {
9292 ratelimiter : Arc :: new ( ratelimiter) ,
9393 api_base : "discord.com" ,
9494 api_scheme : Scheme :: HTTPS ,
95- api_version : 6 ,
95+ api_version : config . discord . api_version ,
9696 timeout : config. timeout . map ( |d| d. into ( ) ) ,
9797 } ) ;
9898
You can’t perform that action at this time.
0 commit comments