no commands in pms, also continued work on lol commands
This commit is contained in:
parent
7874cb1728
commit
c364dab600
@ -32,10 +32,10 @@ namespace NadekoBot.Classes.Permissions {
|
||||
if (timeBlackList.ContainsKey(user))
|
||||
return false;
|
||||
|
||||
timeBlackList.TryAdd(user, DateTime.Now);
|
||||
|
||||
if (channel.IsPrivate)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
timeBlackList.TryAdd(user, DateTime.Now);
|
||||
|
||||
try {
|
||||
//is it a permission command?
|
||||
|
@ -5,6 +5,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot;
|
||||
using System.Drawing;
|
||||
using NadekoBot.Extensions;
|
||||
|
||||
namespace NadekoBot.Commands {
|
||||
class LoLCommands : DiscordCommand {
|
||||
@ -23,14 +25,71 @@ namespace NadekoBot.Commands {
|
||||
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"];
|
||||
//todo save this for at least 1 hour
|
||||
Image img = Image.FromFile("data/lol/bg.png");
|
||||
using (Graphics g = Graphics.FromImage(img)) {
|
||||
int statsFontSize = 15;
|
||||
int margin = 5;
|
||||
int imageSize = 75;
|
||||
var normalFont = new Font("Times New Roman", 9, FontStyle.Regular);
|
||||
//draw champ image
|
||||
g.DrawImage(Image.FromFile($"data/lol/champions/{data["title"].ToString()}.png"), new Rectangle(margin, margin, imageSize, imageSize));
|
||||
//draw champ name
|
||||
g.DrawString($"{data["title"]}", new Font("Times New Roman", 25, FontStyle.Regular), Brushes.WhiteSmoke, margin + imageSize + margin, margin);
|
||||
//draw champ surname
|
||||
//todo
|
||||
//draw roles
|
||||
g.DrawString(
|
||||
@" Average Stats
|
||||
|
||||
Kills: 5.12 CS: 250.5
|
||||
Deaths: 0.01 Win: 99%
|
||||
Assists: 6.55 Ban: 10%
|
||||
", normalFont, Brushes.WhiteSmoke, img.Width - 150, margin);
|
||||
//draw masteries
|
||||
g.DrawString($"MASTERIES: 18 / 0 / 12", normalFont, Brushes.WhiteSmoke, margin, margin + imageSize + margin + 20);
|
||||
//draw runes
|
||||
g.DrawString(@"RUNES
|
||||
9 x Greater Mark of Attack Damage
|
||||
9 x Greater Glyph of Scaling Magic Resist
|
||||
9 x Greater Seal of Armor
|
||||
3 x Greater Quintessence of Attack Speed", normalFont, Brushes.WhiteSmoke, margin, margin + imageSize + margin + 40);
|
||||
//draw counters
|
||||
int smallImgSize = 50;
|
||||
var counters = new string[] { "Yasuo", "Yasuo", "Yasuo" };
|
||||
for (int i = 0; i < counters.Length; i++) {
|
||||
g.DrawImage(Image.FromFile("data/lol/champions/" + counters[i] + ".png"), new Rectangle(i * (smallImgSize + margin) + margin, img.Height - smallImgSize - margin, smallImgSize, smallImgSize));
|
||||
}
|
||||
//draw countered by
|
||||
var countered = new string[] { "Yasuo", "Yasuo", "Yasuo" };
|
||||
for (int i = 0; i < countered.Length; i++) {
|
||||
g.DrawImage(Image.FromFile("data/lol/champions/" + counters[i] + ".png"), new Rectangle(i * (smallImgSize + margin) + margin, img.Height - smallImgSize - margin, smallImgSize, smallImgSize));
|
||||
}
|
||||
//draw item build
|
||||
var build = new string[] { "Bloodthirster", "Bloodthirster", "Bloodthirster", "Bloodthirster", "Bloodthirster", "Bloodthirster" };
|
||||
/*
|
||||
int kdkdPosTop = 75;
|
||||
Font kdkdFont = new Font("Bodoni MT", statsFontSize, FontStyle.Regular);
|
||||
string killsString = "Kills:";
|
||||
SizeF killsSize = g.MeasureString(killsString, kdkdFont);
|
||||
string deathsString = "Deaths:";
|
||||
SizeF deathsSize = g.MeasureString(deathsString, kdkdFont);
|
||||
string k_dString = "K/D:";
|
||||
SizeF k_dSize = g.MeasureString(k_dString, kdkdFont);
|
||||
// g.DrawString(k_dString, Brushes.WhiteSmoke,200, kdkdPosTop);
|
||||
g.DrawString($" {general["kills"]} { general["deaths"]} { float.Parse(general["kills"].ToString()) / float.Parse(general["deaths"].ToString()):f2}"
|
||||
,new Font("Bodoni MT", statsFontSize, FontStyle.Regular), Brushes.OrangeRed, 200, kdkdPosTop);
|
||||
*/
|
||||
}
|
||||
await e.Channel.SendFile(data["title"] + "_stats.png", img.ToStream());
|
||||
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) {
|
||||
catch (Exception ex) {
|
||||
await e.Channel.SendMessage("💢 Failed retreiving data for that champion.");
|
||||
return;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user