Fix endpoints not rendering objects correctly

This commit is contained in:
Daniel_I_Am 2020-08-24 22:19:46 +02:00
parent f56e9c7e42
commit 95388d65e5
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -60,12 +60,7 @@ namespace ChaosBot.WebServer.App
string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
DiscordUserResponse userResponse = JsonConvert.DeserializeObject<DiscordUserResponse>(responseString); DiscordUserResponse userResponse = JsonConvert.DeserializeObject<DiscordUserResponse>(responseString);
return Json(new return Json(userResponse);
{
id = userResponse.id,
username = $"{userResponse.username}#{userResponse.discriminator}",
avatar = userResponse.avatar
});
} }
[HttpGet("guilds")] [HttpGet("guilds")]
@ -90,40 +85,39 @@ namespace ChaosBot.WebServer.App
internal class DiscordOauthResponse internal class DiscordOauthResponse
{ {
public string error = null; public string error { get; set; } = null;
public string error_description = null; public string error_description { get; set; } = null;
public string access_token { get; set; } = null;
public string access_token = null; public int expires_in { get; set; } = 0;
public int expires_in = 0; public string refresh_token { get; set; } = null;
public string refresh_token = null; public string scope { get; set; } = null;
public string scope = null; public string token_type { get; set; } = null;
public string token_type = null;
} }
public class DiscordUserResponse public class DiscordUserResponse
{ {
public string id; public string id { get; set; }
public string username; public string username { get; set; }
public string discriminator; public string discriminator { get; set; }
public string avatar = null; public string avatar { get; set; } = null;
public bool bot = false; public bool bot { get; set; } = false;
public bool system = false; public bool system { get; set; } = false;
public bool mfa_enabled = false; public bool mfa_enabled { get; set; } = false;
public string locale = null; public string locale { get; set; } = null;
public bool verified = false; public bool verified { get; set; } = false;
public string email = null; public string email { get; set; } = null;
public int flags = 0; public int flags { get; set; } = 0;
public int premium_type = 0; public int premium_type { get; set; } = 0;
public int public_flags = 0; public int public_flags { get; set; } = 0;
} }
public class DiscordGuildResponse public class DiscordGuildResponse
{ {
public string id; public string id { get; set; }
public string name; public string name { get; set; }
public string icon; public string icon { get; set; }
public bool owner; public bool owner { get; set; }
public int permissions; public int permissions { get; set; }
public int permissions_new; public int permissions_new { get; set; }
} }
} }