@@ -17,6 +17,8 @@ pub struct MainInfo {
1717 pub max_players : i32 ,
1818 #[ serde( rename = "inQue" ) ]
1919 pub in_que : Option < i32 > ,
20+ #[ serde( rename = "inSpectator" ) ]
21+ pub in_spectator : Option < i32 > ,
2022 #[ serde( rename = "smallMode" ) ]
2123 pub small_mode : String ,
2224 #[ serde( rename = "currentMap" ) ]
@@ -49,6 +51,8 @@ pub struct DetailedInfo {
4951 pub max_players : i32 ,
5052 #[ serde( rename = "inQueue" ) ]
5153 pub in_que : Option < i32 > ,
54+ #[ serde( rename = "inSpectator" ) ]
55+ pub in_spectator : Option < i32 > ,
5256 #[ serde( rename = "smallmode" ) ]
5357 pub small_mode : String ,
5458 #[ serde( rename = "prefix" ) ]
@@ -219,6 +223,7 @@ async fn get(statics: message::Static, game_id: &String) -> Result<ServerInfo> {
219223 DetailedInfo {
220224 current_players : payload. current_players ,
221225 max_players : payload. max_players ,
226+ in_spectator : payload. in_spectator ,
222227 in_que : payload. in_que ,
223228 small_mode : payload. small_mode ,
224229 server_name : payload
@@ -255,23 +260,23 @@ pub async fn change_name(
255260 statics : message:: Static ,
256261 game_id : & String ,
257262) -> Result < ServerInfo > {
258- let status = match get ( statics, game_id) . await {
263+ let status = match get ( statics. clone ( ) , game_id) . await {
259264 Ok ( status) => {
260- let mut server_info = format ! (
261- "{}/{} [{}] - {}" ,
265+ let server_info = format ! (
266+ "{}/{}{}{} - {}" ,
262267 status. detailed. current_players,
263268 status. detailed. max_players,
264- status. detailed. in_que. unwrap_or( 0 ) ,
265- status. detailed. server_map,
269+ match status. detailed. in_que. unwrap_or( 0 ) > 0 {
270+ true => format!( " [{}]" , status. detailed. in_que. unwrap_or( 0 ) ) ,
271+ false => "" . to_string( ) ,
272+ } ,
273+ match & statics. include_spectators[ ..] == "yes" {
274+ true => format!( " ({})" , status. detailed. in_spectator. unwrap_or( 0 ) ) ,
275+ false => "" . to_string( ) ,
276+ } ,
277+ status. detailed. server_map
266278 ) ;
267- if status. detailed . in_que . unwrap_or ( 0 ) == 0 {
268- server_info = format ! (
269- "{}/{} - {}" ,
270- status. detailed. current_players,
271- status. detailed. max_players,
272- status. detailed. server_map,
273- ) ;
274- }
279+
275280 // change game activity
276281 ctx. set_activity ( Some ( ActivityData :: playing ( server_info) ) ) ;
277282
0 commit comments