diff --git a/Commands/AltChecker.cs b/Commands/AltChecker.cs
index ffca937e..699a0b3a 100644
--- a/Commands/AltChecker.cs
+++ b/Commands/AltChecker.cs
@@ -8,6 +8,8 @@
namespace Coflnet.Sky.Commands.MC;
public class AltChecker
{
+ private const string StatsBaseUrl = "https://sky.shiiiyu.moe";
+
///
/// Returns 0-100 probability of the player being an alt
///
@@ -16,14 +18,29 @@ public class AltChecker
public async Task AltLevel(string uuid)
{
var client = new RestClient();
- var request = new RestRequest($"https://sky.shiiyu.moe/api/v2/coins/{uuid}", Method.Get);
+ var request = new RestRequest($"{StatsBaseUrl}/api/v2/coins/{uuid}", Method.Get);
var response = await client.ExecuteGetAsync(request);
- if(response.Content.Contains("no SkyBlock profile"))
+ if (string.IsNullOrWhiteSpace(response.Content))
+ return -1;
+
+ if (response.Content.Contains("no SkyBlock profile", StringComparison.OrdinalIgnoreCase))
{
- await client.ExecuteGetAsync(new RestRequest($"https://sky.shiiyu.moe/stats/{uuid}")); // request profile loading
+ await client.ExecuteGetAsync(new RestRequest($"{StatsBaseUrl}/stats/{uuid}")); // request profile loading
return -1;
}
- var result = JsonConvert.DeserializeObject(response.Content);
+ Response result;
+ try
+ {
+ result = JsonConvert.DeserializeObject(response.Content);
+ }
+ catch (JsonException)
+ {
+ return -1;
+ }
+
+ if (result?.profiles == null || result.profiles.Count == 0)
+ return -1;
+
var maxPurse = result.profiles.Values.Max(p => p.purse);
return (int)Math.Max((20_000_000 - maxPurse) / 1_000_000 * 5, 0);
}
diff --git a/Commands/Flipping/ProfileOpenCommand.cs b/Commands/Flipping/ProfileOpenCommand.cs
index ae351be1..2ef423e7 100644
--- a/Commands/Flipping/ProfileOpenCommand.cs
+++ b/Commands/Flipping/ProfileOpenCommand.cs
@@ -13,7 +13,7 @@ await socket.TryAsyncTimes(async () =>
span.SetTag("name", name);
socket.ExecuteCommand($"/pv {name}");
socket.Dialog(db => db.MsgLine($"Opened profile for ยง6{name}\n{McColorCodes.RESET}If nothing opens you can click this to put the name in chat", "suggest:/pv " + name, "Click to put the name in chat")
- .LineBreak().MsgLine("Or open on skycrypt", "https://sky.shiiyu.moe/stats/" + name));
+ .LineBreak().MsgLine("Or open on skycrypt", "https://sky.shiiiyu.moe/stats/" + name));
}, "opening player profile");
}
-}
\ No newline at end of file
+}