Skip to content

Commit

Permalink
Links oppg, rank emblem working on embed
Browse files Browse the repository at this point in the history
  • Loading branch information
elrick97 committed Dec 22, 2021
1 parent b8037e8 commit 366a938
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 11 deletions.
33 changes: 26 additions & 7 deletions Summoner.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from PIL import Image


class Summoner:
def __init__(self, profile, stats):
regions = {
""
}

def __init__(self, profile, stats, nregion):
self.name = stats[0]['summonerName']
self.profile_icon_id = profile['profileIconId']
self.profile_icon = f'https://ddragon.leagueoflegends.com/cdn/11.24.1/img/profileicon/{self.profile_icon_id}.png'
Expand All @@ -13,8 +15,25 @@ def __init__(self, profile, stats):
self.wins = stats[0]['wins']
self.losses = stats[0]['losses']
self.wr = int((self.wins/(self.wins+self.losses)) * 100)
#self.emblem = self.getEmblem(self.tier)
#self.opgg_url = f'https://{self.region}.op.gg/summoner/userName={self.name}'
self.emblem = f'https://lolg-cdn.porofessor.gg/img/s/league-icons-v2/160/{self.getEmblemId()}-1.png'
self.opgg_url = f'https://{nregion}.op.gg/summoner/userName={self.name}'

# def getEmblem(tier):
# return Image.open(f'./ranked-emblems/{tier}.png')
def getEmblemId(self) -> str:
if(self.tier == 'IRON'):
return 1
elif(self.tier == 'BRONZE'):
return 2
elif(self.tier == 'SILVER'):
return 3
elif(self.tier == 'GOLD'):
return 4
elif(self.tier == 'PLATINUM'):
return 5
elif(self.tier == 'DIAMOND'):
return 6
elif(self.tier == 'MASTER'):
return 7
elif(self.tier == 'GRANDMASTER'):
return 8
elif(self.tier == 'CHALLENGER'):
return 9
7 changes: 4 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ async def on_ready():

@client.command()
async def whois(ctx, region, id):
print('command whois called')
res = await riotApi.getSummoner(region, id)
embed = discord.Embed()
embed.set_author(name=res.name, icon_url=res.profile_icon)
embed.set_author(name=res.name, url=res.opgg_url,
icon_url=res.profile_icon)
embed.title = f'{res.tier} {res.rank}'
embed.add_field(name=res.name, value=res.rank, inline=False)
#embed.thumbnail = res.emblem
embed.set_thumbnail(url=res.emblem)
await ctx.send(embed=embed)
print('command whois called')


client.run(discord_key)
Binary file removed ranked-emblems/BRONZE.png
Binary file not shown.
Binary file removed ranked-emblems/CHALLENGER.png
Binary file not shown.
Binary file removed ranked-emblems/DIAMOND.png
Binary file not shown.
Binary file removed ranked-emblems/GOLD.png
Binary file not shown.
Binary file removed ranked-emblems/GRANDMASTER.png
Binary file not shown.
Binary file removed ranked-emblems/IRON.png
Binary file not shown.
Binary file removed ranked-emblems/MASTER.png
Binary file not shown.
Binary file removed ranked-emblems/PLATINUM.png
Binary file not shown.
Binary file removed ranked-emblems/SILVER.png
Binary file not shown.
4 changes: 3 additions & 1 deletion riotApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


async def getSummoner(region, name):
nregion = region
region = region.lower()
if region not in regions:
print("Region not found!")
Expand All @@ -30,7 +31,8 @@ async def getSummoner(region, name):
print(region, name)
me = watcher.summoner.by_name(region, name)
my_ranked_stats = watcher.league.by_summoner(region, me['id'])
return Summoner(me, my_ranked_stats)
print(me, my_ranked_stats)
return Summoner(me, my_ranked_stats, nregion)
except:
print("summoner not found")
return "Summoner not found."
Expand Down

0 comments on commit 366a938

Please sign in to comment.