fixed ~ani and ~mang, added $shuffle

This commit is contained in:
Master Kwoth 2016-01-25 14:10:15 +01:00
parent 63bf61cdd7
commit 5933bb9830
2 changed files with 25 additions and 5 deletions

View File

@ -13,7 +13,9 @@ namespace NadekoBot
{ {
private Cards cards = null; private Cards cards = null;
public DrawCommand() : base() { } public DrawCommand() : base() {
cards = new Cards();
}
public override Func<CommandEventArgs, Task> DoFunc() => async (e) => public override Func<CommandEventArgs, Task> 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]") .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) .Parameter("count", ParameterType.Optional)
.Do(DoFunc()); .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.");
});
} }
} }

View File

@ -142,7 +142,7 @@ namespace NadekoBot.Modules
{ {
try 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); var rq = new RestSharp.RestRequest("/auth/access_token", RestSharp.Method.POST);
RefreshToken(); RefreshToken();
@ -168,7 +168,7 @@ namespace NadekoBot.Modules
{ {
RefreshToken(); 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); var rq = new RestSharp.RestRequest("/auth/access_token", RestSharp.Method.POST);
rq = new RestSharp.RestRequest("/manga/search/"+Uri.EscapeUriString(query)); rq = new RestSharp.RestRequest("/manga/search/"+Uri.EscapeUriString(query));
rq.AddParameter("access_token", token); rq.AddParameter("access_token", token);
@ -188,12 +188,19 @@ namespace NadekoBot.Modules
private void RefreshToken() 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); var rq = new RestSharp.RestRequest("/auth/access_token", RestSharp.Method.POST);
rq.AddParameter("grant_type", "client_credentials"); rq.AddParameter("grant_type", "client_credentials");
rq.AddParameter("client_id", "kwoth-w0ki9"); rq.AddParameter("client_id", "kwoth-w0ki9");
rq.AddParameter("client_secret", "Qd6j4FIAi1ZK6Pc7N7V4Z"); 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<bool> ValidateQuery(Discord.Channel ch,string query) { private static async Task<bool> ValidateQuery(Discord.Channel ch,string query) {