@@ -17,6 +17,8 @@ pub struct MainInfo {
17
17
pub max_players : i32 ,
18
18
#[ serde( rename = "inQue" ) ]
19
19
pub in_que : Option < i32 > ,
20
+ #[ serde( rename = "inSpectator" ) ]
21
+ pub in_spectator : Option < i32 > ,
20
22
#[ serde( rename = "smallMode" ) ]
21
23
pub small_mode : String ,
22
24
#[ serde( rename = "currentMap" ) ]
@@ -49,6 +51,8 @@ pub struct DetailedInfo {
49
51
pub max_players : i32 ,
50
52
#[ serde( rename = "inQueue" ) ]
51
53
pub in_que : Option < i32 > ,
54
+ #[ serde( rename = "inSpectator" ) ]
55
+ pub in_spectator : Option < i32 > ,
52
56
#[ serde( rename = "smallmode" ) ]
53
57
pub small_mode : String ,
54
58
#[ serde( rename = "prefix" ) ]
@@ -219,6 +223,7 @@ async fn get(statics: message::Static, game_id: &String) -> Result<ServerInfo> {
219
223
DetailedInfo {
220
224
current_players : payload. current_players ,
221
225
max_players : payload. max_players ,
226
+ in_spectator : payload. in_spectator ,
222
227
in_que : payload. in_que ,
223
228
small_mode : payload. small_mode ,
224
229
server_name : payload
@@ -255,23 +260,23 @@ pub async fn change_name(
255
260
statics : message:: Static ,
256
261
game_id : & String ,
257
262
) -> Result < ServerInfo > {
258
- let status = match get ( statics, game_id) . await {
263
+ let status = match get ( statics. clone ( ) , game_id) . await {
259
264
Ok ( status) => {
260
- let mut server_info = format ! (
261
- "{}/{} [{}] - {}" ,
265
+ let server_info = format ! (
266
+ "{}/{}{}{} - {}" ,
262
267
status. detailed. current_players,
263
268
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
266
278
) ;
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
+
275
280
// change game activity
276
281
ctx. set_activity ( Some ( ActivityData :: playing ( server_info) ) ) ;
277
282
0 commit comments