File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ pub struct Config {
12
12
pub redis : RedisConfig ,
13
13
#[ serde( default ) ]
14
14
pub amqp : AmqpConfig ,
15
+ #[ serde( default ) ]
16
+ pub discord : DiscordConfig ,
15
17
#[ serde( default , deserialize_with = "deserialize_duration" ) ]
16
18
pub timeout : Option < Duration > ,
17
19
}
@@ -56,6 +58,7 @@ impl Config {
56
58
"AMQP_EVENT" => self . amqp . event = v,
57
59
"AMQP_CANCELLATION_EVENT" => self . amqp . cancellation_event = v,
58
60
"TIMEOUT" => self . timeout = v. parse ( ) . ok ( ) ,
61
+ "DISCORD_API_VERSION" => self . discord . api_version = v. parse ( ) . expect ( "valid DISCORD_API_VERSION (u8)" ) ,
59
62
_ => { }
60
63
}
61
64
}
@@ -127,3 +130,23 @@ impl Default for AmqpConfig {
127
130
}
128
131
}
129
132
}
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() {
92
92
ratelimiter : Arc :: new ( ratelimiter) ,
93
93
api_base : "discord.com" ,
94
94
api_scheme : Scheme :: HTTPS ,
95
- api_version : 6 ,
95
+ api_version : config . discord . api_version ,
96
96
timeout : config. timeout . map ( |d| d. into ( ) ) ,
97
97
} ) ;
98
98
You can’t perform that action at this time.
0 commit comments