mirror of
https://github.com/Floriansylvain/Risitas_BOT.git
synced 2026-08-19 11:43:16 +02:00
✨ - Introducing the new command $lol_lastgame !
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<h1 align="center">🤖 Risitas Discord Bot 🤖</h1>
|
<h1 align="center">🤖 Risitas Discord Bot 🤖</h1>
|
||||||
<p>
|
<p>
|
||||||
<img alt="Version" src="https://img.shields.io/badge/version-1.5-blue.svg?cacheSeconds=2592000" />
|
<img alt="Version" src="https://img.shields.io/badge/version-1.6-blue.svg?cacheSeconds=2592000" />
|
||||||
<a href="#" target="_blank">
|
<a href="#" target="_blank">
|
||||||
<img alt="License: GPL 3.0" src="https://img.shields.io/badge/License-GPL%203.0-yellow" />
|
<img alt="License: GPL 3.0" src="https://img.shields.io/badge/License-GPL%203.0-yellow" />
|
||||||
</a>
|
</a>
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@@ -63,6 +67,13 @@ $lol_rank {lol_username}
|
|||||||
This command will display a message with the current League of Legend rank of the EUW account you ask for. Make sure to use quotes if there is spaces in the LoL username.
|
This command will display a message with the current League of Legend rank of the EUW account you ask for. Make sure to use quotes if there is spaces in the LoL username.
|
||||||
|
|
||||||
|
|
||||||
|
### **lol_lastgame**
|
||||||
|
```
|
||||||
|
$lol_lastgame {lol_username}
|
||||||
|
```
|
||||||
|
This command will display a summary (which team won, players, damages, kda...) of the last League of Legend game of the EUW account you ask for.
|
||||||
|
|
||||||
|
|
||||||
## Osu!
|
## Osu!
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
@@ -1,5 +1,6 @@
|
|||||||
from riotwatcher import LolWatcher, ApiError
|
from riotwatcher import LolWatcher, ApiError
|
||||||
from private import TOKEN_RIOT
|
from private import TOKEN_RIOT
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
WATCHER = LolWatcher(TOKEN_RIOT)
|
WATCHER = LolWatcher(TOKEN_RIOT)
|
||||||
REGION = 'EUW1'
|
REGION = 'EUW1'
|
||||||
@@ -10,6 +11,7 @@ def what_player(name):
|
|||||||
except ApiError:
|
except ApiError:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def rank_track(player):
|
def rank_track(player):
|
||||||
ranked_stats = WATCHER.league.by_summoner(REGION, player['id'])
|
ranked_stats = WATCHER.league.by_summoner(REGION, player['id'])
|
||||||
if not ranked_stats:
|
if not ranked_stats:
|
||||||
@@ -22,3 +24,28 @@ def rank_track(player):
|
|||||||
what_rank = 'Flexible'
|
what_rank = 'Flexible'
|
||||||
liste.append([what_rank, infos['tier'], infos['rank'], infos['leaguePoints'], infos['wins'], infos['losses']])
|
liste.append([what_rank, infos['tier'], infos['rank'], infos['leaguePoints'], infos['wins'], infos['losses']])
|
||||||
return liste
|
return liste
|
||||||
|
|
||||||
|
|
||||||
|
def last_match(player):
|
||||||
|
matches = WATCHER.match.matchlist_by_account('EUW1', player['accountId'])
|
||||||
|
recent_match = matches['matches'][0]
|
||||||
|
match_detail = WATCHER.match.by_id('EUW1', recent_match['gameId'])
|
||||||
|
lst = [[],[[],[]]]
|
||||||
|
for x, y in zip(match_detail['participants'], match_detail['participantIdentities']):
|
||||||
|
lst[0].append([y['player']['summonerName'],
|
||||||
|
x['stats']['totalDamageDealtToChampions'],
|
||||||
|
x['stats']['kills'],
|
||||||
|
x['stats']['deaths'],
|
||||||
|
x['stats']['assists']])
|
||||||
|
|
||||||
|
for team in match_detail['teams']:
|
||||||
|
lst[1][0].append(team['win'])
|
||||||
|
lst[1][1].append(team['firstBlood'])
|
||||||
|
|
||||||
|
ts = str(match_detail['gameCreation'])[:-3]
|
||||||
|
dt = datetime.fromtimestamp(int(ts)).date()
|
||||||
|
|
||||||
|
lst.append(str(dt))
|
||||||
|
lst.append(str(timedelta(seconds=match_detail['gameDuration'])))
|
||||||
|
|
||||||
|
return lst
|
||||||
|
|||||||
+40
-1
@@ -3,7 +3,7 @@ import asyncio
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands.cooldowns import BucketType
|
from discord.ext.commands.cooldowns import BucketType
|
||||||
from private import TOKEN_RIOT
|
from private import TOKEN_RIOT
|
||||||
from api_riot import rank_track, what_player
|
from api_riot import rank_track, what_player, last_match
|
||||||
|
|
||||||
CD_LOLRANK = 0
|
CD_LOLRANK = 0
|
||||||
|
|
||||||
@@ -39,6 +39,45 @@ class LolCmds(commands.Cog, name='League of Legend commands'):
|
|||||||
await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
|
await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
|
||||||
|
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def lol_lastgame(self, ctx, invocator_name, x=None):
|
||||||
|
if x is None:
|
||||||
|
player = what_player(invocator_name)
|
||||||
|
if player != 0:
|
||||||
|
lst = last_match(player)
|
||||||
|
lst_p = lst[0]
|
||||||
|
maximum = lst_p[0][1]
|
||||||
|
for stat in lst_p:
|
||||||
|
if stat[1] > maximum:
|
||||||
|
maximum = stat[1]
|
||||||
|
tab, players, kda = [], [], []
|
||||||
|
for stat in lst_p:
|
||||||
|
pourcent = round(100*stat[1]/maximum)
|
||||||
|
equals = int(round(float(pourcent)/3.3))
|
||||||
|
hyphen = 30 - equals
|
||||||
|
tab.append('[' + '='*equals + '-'*hyphen +']\n')
|
||||||
|
players.append(stat[0] + '\n')
|
||||||
|
kda.append(str(stat[2]) + '/' + str(stat[3]) + '/' + str(stat[4]) + '\n')
|
||||||
|
embed = discord.Embed(title=invocator_name, url='https://bit.ly/3biTekM',
|
||||||
|
description='Date: ' + lst[2] + '\nLength: ' + lst[3])
|
||||||
|
embed.set_author(name='League Of Legend - Last Game', url='https://euw.leagueoflegends.com/en-gb/',
|
||||||
|
icon_url='https://static.wikia.nocookie.net/leagueoflegends/images/0/07/' +
|
||||||
|
'League_of_Legends_icon.png/revision/latest?cb=20191018194326')
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
for i in range(0, -2, -1):
|
||||||
|
embed = discord.Embed(title='Team 1' if not i else 'Team 2', colour=
|
||||||
|
discord.Colour.green() if lst[1][0][i] == 'Win' else discord.Colour.red(),
|
||||||
|
description=':drop_of_blood: First blood' if lst[1][1][i] else None)
|
||||||
|
embed.add_field(name='Players', value='```\n' + ''.join(players[:5] if not i else players[5:]) + '```')
|
||||||
|
embed.add_field(name='Total damage dealt to champions', value='```\n' + ''.join(tab[:5] if not i else tab[5:]) + '```')
|
||||||
|
embed.add_field(name='K / D / A', value='```\n' + ''.join(kda[:5] if not i else kda[5:]) + '```')
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
else:
|
||||||
|
await ctx.send('The username you entered is unknown.')
|
||||||
|
else:
|
||||||
|
await ctx.send('If you are trying to use a username with spaces, please surround it with quotes.')
|
||||||
|
|
||||||
|
|
||||||
@lol_rank.error
|
@lol_rank.error
|
||||||
async def lolrank_error(self, ctx, error):
|
async def lolrank_error(self, ctx, error):
|
||||||
global CD_LOLRANK
|
global CD_LOLRANK
|
||||||
|
|||||||
Reference in New Issue
Block a user