diff --git a/DeukBot4/APIHandlers/CatFactsApi.cs b/DeukBot4/APIHandlers/AnimalFactsApi.cs similarity index 68% rename from DeukBot4/APIHandlers/CatFactsApi.cs rename to DeukBot4/APIHandlers/AnimalFactsApi.cs index 103b94b..66c6b68 100644 --- a/DeukBot4/APIHandlers/CatFactsApi.cs +++ b/DeukBot4/APIHandlers/AnimalFactsApi.cs @@ -1,22 +1,20 @@ using System; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace DeukBot4.APIHandlers { - public static class CatFactsApi + public static class AnimalFactsApi { - private const string URL = "http://api.levi506.net/"; + private const string URL = "https://api.levi506.net/"; - public static async Task GetRandomCatFact() + public static async Task GetRandomCatFact(string animal) { var client = new HttpClient {BaseAddress = new Uri(URL)}; client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - var response = await client.GetAsync("fact/animal/cat"); // Blocking call! + var response = await client.GetAsync("/v1/fact/animal/" + animal); // Blocking call! if (!response.IsSuccessStatusCode) return null; diff --git a/DeukBot4/DeukBot4.csproj b/DeukBot4/DeukBot4.csproj index 5a714a9..00b2ba0 100644 --- a/DeukBot4/DeukBot4.csproj +++ b/DeukBot4/DeukBot4.csproj @@ -5,9 +5,9 @@ 7.1 - + - + \ No newline at end of file diff --git a/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs b/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs index b5462d4..17d13c2 100644 --- a/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs +++ b/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs @@ -114,12 +114,20 @@ namespace DeukBot4.MessageHandlers.CommandHandler } [Command("catfact", PermissionLevel.Everyone)] - [CommandHelp("Returns a random cat fact", "Returns a random cat fact, powered by https://catfact.ninja/")] + [CommandHelp("Returns a random cat fact", "Returns a random cat fact")] public async Task RandomCatFact(CommandRequest request) { - await request.SendSimpleEmbed("Cat Fact", await CatFactsApi.GetRandomCatFact()); + await request.SendSimpleEmbed("Cat Fact", await AnimalFactsApi.GetRandomCatFact("cat")); } + [Command("dogfact", PermissionLevel.Everyone)] + [CommandHelp("Returns a random dog fact", "Returns a random cat fact")] + public async Task RandomDogFact(CommandRequest request) + { + await request.SendSimpleEmbed("Dog Fact", await AnimalFactsApi.GetRandomCatFact("dog")); + } + + [Command("catpic", PermissionLevel.Everyone)] [CommandHelp("Returns a random cat picture", "Returns a random cat picture")] [CommandParameters(ParameterMatcher.ParameterType.Remainder)]