1- use std:: collections:: HashMap ;
2-
31use serenity:: { client:: Context , model:: id:: ChannelId } ;
42use anyhow:: Result ;
53use super :: server_info;
@@ -17,6 +15,7 @@ pub struct Global {
1715pub struct Static {
1816 pub server_id : String ,
1917 pub game : String ,
18+ pub platform : String ,
2019 pub owner_id : String ,
2120 pub fake_players : String ,
2221 pub server_name : String ,
@@ -91,14 +90,27 @@ pub async fn check(ctx: Context, status: server_info::ServerInfo, mut globals: G
9190pub async fn send ( ctx : Context , statics : Static , image_url : & str , status : server_info:: ServerInfo , title : & str ,
9291 description : & str ) -> Result < serenity:: model:: channel:: Message , serenity:: Error > {
9392 let paths = vec ! [ image_url] ;
94- let games = HashMap :: from ( [
93+ let games = std :: collections :: HashMap :: from ( [
9594 ( "tunguska" , "bf1" ) ,
9695 ( "casablanca" , "bfv" ) ,
9796 ( "kingston" , "bf2042" ) ,
9897 ] ) ;
98+ let mut gather_type = "gameid" ;
99+ if statics. game == "kingston" {
100+ gather_type = "serverid" ;
101+ } else if status. game_id . clone ( ) . unwrap_or_default ( ) . contains ( ":" ) {
102+ gather_type = "serverip" ;
103+ }
104+ let server_link = format ! (
105+ "https://gametools.network/servers/{}/{}/{}/{}" ,
106+ games. get( & statics. game[ ..] ) . unwrap_or( &&statics. game[ ..] ) ,
107+ gather_type,
108+ status. game_id. clone( ) . unwrap_or_default( ) ,
109+ statics. platform
110+ ) ;
99111 ChannelId ( statics. message_channel ) . send_files ( & ctx. http , paths, |m| {
100112 m. embed ( |e| {
101- e. url ( format ! ( "https://gametools.network/servers/{}/gameid/{}/pc" , games . get ( & statics . game [ .. ] ) . unwrap_or ( &&statics . game [ .. ] ) , status . game_id . unwrap_or_default ( ) ) ) ;
113+ e. url ( server_link ) ;
102114 e. title ( title) ;
103115 e. description ( description) ;
104116 e. footer ( |f| {
0 commit comments