From 5933bb98307fbfb8a52fa16ecc0cd06db8c2d425 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 25 Jan 2016 14:10:15 +0100 Subject: [PATCH] fixed ~ani and ~mang, added $shuffle --- NadekoBot/Commands/DrawCommand.cs | 15 ++++++++++++++- NadekoBot/Modules/Searches.cs | 15 +++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/NadekoBot/Commands/DrawCommand.cs b/NadekoBot/Commands/DrawCommand.cs index e57939c0..20dea427 100644 --- a/NadekoBot/Commands/DrawCommand.cs +++ b/NadekoBot/Commands/DrawCommand.cs @@ -13,7 +13,9 @@ namespace NadekoBot { private Cards cards = null; - public DrawCommand() : base() { } + public DrawCommand() : base() { + cards = new Cards(); + } public override Func DoFunc() => async (e) => { @@ -67,6 +69,17 @@ namespace NadekoBot .Description("Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck.\n**Usage**: $draw [x]") .Parameter("count", ParameterType.Optional) .Do(DoFunc()); + + cgb.CreateCommand("$shuffle") + .Alias("$reshuffle") + .Description("Reshuffles all cards back into the deck.") + .Do(async e => { + if (cards == null) { + cards = new Cards(); + } + cards.Restart(); + await e.Send("Deck reshuffled."); + }); } } diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index 815ef6ce..77094f9e 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -142,7 +142,7 @@ namespace NadekoBot.Modules { try { - var cl = new RestSharp.RestClient("https://anilist.co/api"); + var cl = new RestSharp.RestClient("http://anilist.co/api"); var rq = new RestSharp.RestRequest("/auth/access_token", RestSharp.Method.POST); RefreshToken(); @@ -168,7 +168,7 @@ namespace NadekoBot.Modules { RefreshToken(); - var cl = new RestSharp.RestClient("https://anilist.co/api"); + var cl = new RestSharp.RestClient("http://anilist.co/api"); var rq = new RestSharp.RestRequest("/auth/access_token", RestSharp.Method.POST); rq = new RestSharp.RestRequest("/manga/search/"+Uri.EscapeUriString(query)); rq.AddParameter("access_token", token); @@ -188,12 +188,19 @@ namespace NadekoBot.Modules private void RefreshToken() { - var cl = new RestSharp.RestClient("https://anilist.co/api"); + var cl = new RestSharp.RestClient("http://anilist.co/api"); var rq = new RestSharp.RestRequest("/auth/access_token", RestSharp.Method.POST); rq.AddParameter("grant_type", "client_credentials"); rq.AddParameter("client_id", "kwoth-w0ki9"); rq.AddParameter("client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"); - token = JObject.Parse(cl.Execute(rq).Content)["access_token"].ToString(); + var exec = cl.Execute(rq); + /* + Console.WriteLine($"Server gave me content: { exec.Content }\n{ exec.ResponseStatus } -> {exec.ErrorMessage} "); + Console.WriteLine($"Err exception: {exec.ErrorException}"); + Console.WriteLine($"Inner: {exec.ErrorException.InnerException}"); + */ + + token = JObject.Parse(exec.Content)["access_token"].ToString(); } private static async Task ValidateQuery(Discord.Channel ch,string query) {