jsvana / async-minecraft-ping

ServerListPing in Rust
Apache License 2.0
13 stars 5 forks source link

unable to parse the status description to a discord webhook #18

Open ZaneIcezMaster11 opened 1 year ago

ZaneIcezMaster11 commented 1 year ago

So what im doing is very simple. Its trying to get server info from a certain ip and port using this package and when trying to get the motd, i use status.status.description to set it in a mut variable. The problem is that when trying to parse this info to my webhook, nothing works. Ive tried casting it into different variables, and trying to convert the struct to json packages. I have other things like max players and players online working just fine, but this is giving me issues. Is there any way you know to fix this or cast this to a usable variable that i can give to the webhook to print? My Code for this ill be link down below.

let connection = config.connect().await.expect("Invalid Ip");
            let status = connection.status().await.expect("No Ping from server");
let client = WebhookClient::new(&url);
            //println!("{:#?}", serverImage);
            //sends message to the webhook
            client.send(|message| message
                .username("Eoka Scanner")
                .avatar_url(IMAGE_URL)
                .embed(|embed| embed
                    .title(&ip)
                    .description("description") {this is where the motd is trying to be printed its set to a default text rn because it gives errrors}
                    //.image(&serverImage.as_str())
                    .field(&"online/max".replace("online", &onlinePlayers.to_string()).replace("max", &maxPlayers.to_string()), "users matching search", false))).await?;
    }

Any possible solutions or insight into my problems would be nice. Any questions you have about this i can answer

TheUnsocialEngineer commented 1 year ago

following the code in https://github.com/ewpratten/mcq/blob/master/src/main.rs specifically let description = match status.description { ServerDescription::Plain(str) => str, ServerDescription::Object { text } => text, };you can then call description in the webhook or anywhere else you need the value