started work on lol commands. (~lolchamp champ name) added

This commit is contained in:
Master Kwoth 2016-02-20 21:33:24 +01:00
parent 5da3492b12
commit 7e295d2b89
3 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Commands;
using NadekoBot;
namespace NadekoBot.Commands {
class LoLCommands : DiscordCommand {
public override Func<CommandEventArgs, Task> DoFunc() {
throw new NotImplementedException();
}
public override void Init(CommandGroupBuilder cgb) {
cgb.CreateCommand("~lolchamp")
.Description("Checks champion statistic for a lol champion.")
.Parameter("region", ParameterType.Unparsed)
.Do(async e => {
if (string.IsNullOrWhiteSpace(e.GetArg("region")))
return;
try {
var arg = e.GetArg("region");
var data = Newtonsoft.Json.Linq.JArray.Parse(await Classes.SearchHelper.GetResponseAsync($"http://api.champion.gg/stats/champs/{e.GetArg("region")}?api_key={NadekoBot.creds.LOLAPIKey}"))[0];
var general = data["general"];
await e.Channel.SendMessage(
$@"**`Champion Name:` {data["title"]}
`Kills:` {general["kills"]} `Deaths:` {general["deaths"]}** `K/D:`**{float.Parse(general["kills"].ToString()) / float.Parse(general["deaths"].ToString()):f2}**
`Minions:` **{general["minionsKilled"]}**
`Win percentage:` **{general["winPercent"]}%**
");
}
catch (Exception) {
await e.Channel.SendMessage("💢 Failed retreiving data for that champion.");
return;
}
});
}
}
}

View File

@ -13,7 +13,7 @@ namespace NadekoBot.Modules {
class Searches : DiscordModule { class Searches : DiscordModule {
private Random _r; private Random _r;
public Searches() : base() { public Searches() : base() {
// commands.Add(new LoLCommands()); commands.Add(new LoLCommands());
_r = new Random(); _r = new Random();
} }

View File

@ -147,6 +147,7 @@
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" /> <Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
<Compile Include="Commands\ClashOfClans.cs" /> <Compile Include="Commands\ClashOfClans.cs" />
<Compile Include="Commands\LogCommand.cs" /> <Compile Include="Commands\LogCommand.cs" />
<Compile Include="Commands\LoLCommands.cs" />
<Compile Include="Commands\TriviaCommand.cs" /> <Compile Include="Commands\TriviaCommand.cs" />
<Compile Include="Classes\Trivia\TriviaGame.cs" /> <Compile Include="Classes\Trivia\TriviaGame.cs" />
<Compile Include="Classes\Trivia\TriviaQuestion.cs" /> <Compile Include="Classes\Trivia\TriviaQuestion.cs" />