diff --git a/NadekoBot/Commands/LoLCommands.cs b/NadekoBot/Commands/LoLCommands.cs new file mode 100644 index 00000000..c521ca05 --- /dev/null +++ b/NadekoBot/Commands/LoLCommands.cs @@ -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 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; + } + }); + } + } +} diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index 3027df42..b7e57963 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -13,7 +13,7 @@ namespace NadekoBot.Modules { class Searches : DiscordModule { private Random _r; public Searches() : base() { - // commands.Add(new LoLCommands()); + commands.Add(new LoLCommands()); _r = new Random(); } diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 6a96ba0f..efe406c5 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -147,6 +147,7 @@ +