Utilize new api
This commit is contained in:
parent
71b05a2bbd
commit
c0f8a49d92
@ -6,11 +6,13 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ChaosBot.Discord.PreConditions;
|
using ChaosBot.Discord.PreConditions;
|
||||||
using ChaosBot.Lodestone;
|
using ChaosBot.Lodestone;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace ChaosBot.Discord.Modules.Admin
|
namespace ChaosBot.Discord.Modules.Admin
|
||||||
@ -107,14 +109,18 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
{
|
{
|
||||||
using HttpClient client = new HttpClient();
|
using HttpClient client = new HttpClient();
|
||||||
|
|
||||||
|
IConfigurationSection configurationSection =
|
||||||
|
Program.AppSettingsHandler.GetSection("Lodestone:ChaosBotApi");
|
||||||
|
string endpoint = configurationSection.GetValue<string>("Url");
|
||||||
|
string apiToken = configurationSection.GetValue<string>("ApiToken");
|
||||||
|
|
||||||
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiToken);
|
||||||
HttpResponseMessage result =
|
HttpResponseMessage result =
|
||||||
await client.GetAsync(
|
await client.GetAsync(endpoint);
|
||||||
ConfigurationRepository.GetValue<string>("Lodestone:RankCheck:Url", discordGuildId));
|
|
||||||
result.EnsureSuccessStatusCode();
|
result.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
response = await result.Content.ReadAsStringAsync();
|
response = await result.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
// return new List<LodestoneRankedUser>();
|
|
||||||
return JsonConvert.DeserializeObject<LodestoneRankApi>(response).Data;
|
return JsonConvert.DeserializeObject<LodestoneRankApi>(response).Data;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user