Ich habe schon eine Weile versucht, dieses Problem zu beheben, aber alles, was ich ausprobiert habe, ist nutzlos. Ich habe es mit HttpclientHandler ausprobiert, aber immer noch den Fehler erhalten! < /p>
Fehlermeldungen: < /p>
SSL -Verbindung konnte nicht hergestellt werden, siehe innere Ausnahme < /p>
Authentifizierung fehlgeschlagen, siehe innere Ausnahme. /> < /blockquote>
[Command("stats")]
public async Task Profileosu([Remainder]string username = null)
{
try
{
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
HttpClient client = new HttpClient(clientHandler,disposeHandler: true);
List player = new List();
List lines = File.ReadAllLines(path, encoding: Encoding.UTF8).ToList();
string id = "";
foreach (var line in lines)
{
string[] readed = line.Split(",");
Player newPlayer = new Player();
newPlayer.id = readed[0];
newPlayer.osuname = readed[1];
player.Add(newPlayer);
}
if (username is null)
{
id = Context.User.Id.ToString();
username = Context.User.Username;
}
else if (Context.Message.MentionedUsers.Count > 0)
{
username = Context.Message.MentionedUsers.First().Username;
id = Context.Message.MentionedUsers.First().Id.ToString();
}
for (int i = 0; i < player.Count(); i++)
{
if (player.id == id)
{
username = player.osuname;
}
}
string url = $"https://osu.ppy.sh/api/get_user?k={k}&u={username}";
string osuProf = await client.GetStringAsync(url);
dynamic osuProfile = JsonConvert.DeserializeObject(value: osuProf);
string pp_raw = osuProfile[0]["pp_raw"];
string country = osuProfile[0]["country"];
string user_id = osuProfile[0]["user_id"];
string joinDate = osuProfile[0]["join_date"];
string rank = osuProfile[0]["pp_rank"];
string countryRank = osuProfile[0]["pp_country_rank"];
string accuracy = osuProfile[0]["accuracy"];
string playcount = osuProfile[0]["playcount"];
string userName = osuProfile[0]["username"];
embed.WithThumbnailUrl($"https://a.ppy.sh/{user_id}");
embed.WithAuthor($"{username} #{rank}, {pp_raw}PP", Context.Guild.CurrentUser.GetAvatarUrl(), $"https://osu.ppy.sh/users/{user_id}");
embed.WithDescription($"Join date:{joinDate}\nCountry:{country} #{countryRank}\n");
embed.WithFooter($"Accuray:{double.Parse(accuracy):F2}%\t\tPlaycount:{playcount}");
embed.WithColor(154, 255, 0);
await ReplyAsync($"", false, embed.Build());
}
catch (Exception ex)
{
embed.WithAuthor("An error occurred");
embed.WithDescription("This player doesn't exist! Please check the username and try again!");
embed.WithColor(255, 0, 0);
await ReplyAsync($"", false, embed.Build());
Console.WriteLine(ex.Message);
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException.Message);
}
if (ex.InnerException.InnerException.Message != null)
{
Console.WriteLine(ex.InnerException.InnerException.Message);
}
}
}
< /code>
Ich lerne C# von Grund auf und ich bin sehr anfänger in der Sprache. Bitte erklären Sie also, was das Problem ist. < /p>
So beheben Sie 'die empfangene Nachricht war unerwartet oder schlecht formatiert' ⇐ C#
-
- Similar Topics
- Replies
- Views
- Last post
Mobile version