mirror of
https://github.com/Floriansylvain/Risitas_BOT.git
synced 2026-08-19 11:43:16 +02:00
💩 - Removed commands related to a shitty game :D
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
from datetime import datetime, timedelta
|
||||
from riotwatcher import LolWatcher, ApiError
|
||||
from private import TOKEN_RIOT
|
||||
|
||||
WATCHER = LolWatcher(TOKEN_RIOT)
|
||||
REGION = 'EUW1'
|
||||
|
||||
|
||||
def what_player(name):
|
||||
try:
|
||||
return WATCHER.summoner.by_name(REGION, name)
|
||||
except ApiError:
|
||||
return 0
|
||||
|
||||
|
||||
def rank_track(player):
|
||||
ranked_stats = WATCHER.league.by_summoner(REGION, player['id'])
|
||||
if not ranked_stats:
|
||||
return 'Unranked cette saison.'
|
||||
liste = []
|
||||
for infos in ranked_stats:
|
||||
if infos['queueType'] == 'RANKED_SOLO_5x5':
|
||||
what_rank = 'Solo Queue'
|
||||
elif infos['queueType'] == 'RANKED_FLEX_SR':
|
||||
what_rank = 'Flexible'
|
||||
liste.append([what_rank, infos['tier'], infos['rank'],
|
||||
infos['leaguePoints'], infos['wins'], infos['losses']])
|
||||
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 participants, details in zip(match_detail['participants'],
|
||||
match_detail['participantIdentities']):
|
||||
lst[0].append([details['player']['summonerName'],
|
||||
participants['stats']['totalDamageDealtToChampions'],
|
||||
participants['stats']['kills'],
|
||||
participants['stats']['deaths'],
|
||||
participants['stats']['assists']])
|
||||
|
||||
for team in match_detail['teams']:
|
||||
lst[1][0].append(team['win'])
|
||||
lst[1][1].append(team['firstBlood'])
|
||||
lst[1][2].append(team['firstTower'])
|
||||
lst[1][3].append(team['firstDragon'])
|
||||
|
||||
time_stamp = str(match_detail['gameCreation'])[:-3]
|
||||
date_time = datetime.fromtimestamp(int(time_stamp)).date()
|
||||
|
||||
lst.append(str(date_time))
|
||||
lst.append(str(timedelta(seconds=match_detail['gameDuration'])))
|
||||
|
||||
return lst
|
||||
@@ -1,77 +0,0 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from api_riot import rank_track, what_player, last_match
|
||||
|
||||
CD_LOLRANK = 0
|
||||
|
||||
|
||||
class LolCmds(commands.Cog, name='League of Legend commands'):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(ignore_extra=False)
|
||||
@commands.cooldown(1, 2, commands.BucketType.user)
|
||||
async def lol_rank(self, ctx, invocator_name):
|
||||
player = what_player(invocator_name)
|
||||
if player != 0:
|
||||
ranks = rank_track(player)
|
||||
embed = discord.Embed(title=invocator_name, url='https://bit.ly/3biTekM')
|
||||
embed.set_thumbnail(url='http://ddragon.leagueoflegends.com/cdn/11.2.1/img/profileicon/' +
|
||||
str(player['profileIconId']) + '.png')
|
||||
embed.set_author(name='League Of Legend - Rank', 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')
|
||||
if isinstance(ranks, list):
|
||||
for rank_s in ranks:
|
||||
embed.add_field(name=rank_s[0], value=str(rank_s[1]) + ' ' +
|
||||
str(rank_s[2]) + ' ' + str(rank_s[3]) + ' LP\n' +
|
||||
str(rank_s[4]) + 'W/' + str(rank_s[5]) +
|
||||
'L', inline=False)
|
||||
else:
|
||||
embed.description = ranks
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
await ctx.send('The username you entered is unknown.')
|
||||
|
||||
@commands.command(ignore_extra=False)
|
||||
@commands.cooldown(1, 2, commands.BucketType.user)
|
||||
async def lol_lastgame(self, ctx, invocator_name):
|
||||
player = what_player(invocator_name)
|
||||
if player != 0:
|
||||
lst = last_match(player)
|
||||
maximum = lst[0][0][1]
|
||||
for stat in lst[0]:
|
||||
if stat[1] > maximum:
|
||||
maximum = stat[1]
|
||||
tab, players, kda = [], [], []
|
||||
for stat in lst[0]:
|
||||
pourcent = round(100*stat[1]/maximum)
|
||||
equals = int(round(float(pourcent)/3.3))
|
||||
tab.append('[' + '=' * equals + ' ' * (30 - equals) + ']\n')
|
||||
players.append(stat[0][:15] + '\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\n' if len(lst[1][1]) != 0 and lst[1][1][i] else '') +
|
||||
(':tokyo_tower: First tower\n' if len(lst[1][2]) != 0 and lst[1][2][i] else '') +
|
||||
(':dragon_face: First dragon\n' if len(lst[1][3]) != 0 and lst[1][3][i] else ''))
|
||||
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.')
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(LolCmds(bot))
|
||||
@@ -1,7 +1,7 @@
|
||||
import asyncio
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from miscellaneous import spellchecker
|
||||
|
||||
class OtherCmds(commands.Cog, name='Other commands'):
|
||||
def __init__(self, bot):
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ from errors import errors
|
||||
print('Loading started')
|
||||
|
||||
bot = commands.Bot(command_prefix='$')
|
||||
startup_extensions = ["cmd_other", "cmd_lol", "cmd_osu", "cmd_twitch", "cmd_owner"]
|
||||
startup_extensions = ["cmd_other", "cmd_osu", "cmd_twitch", "cmd_owner"]
|
||||
|
||||
startup_date = datetime.now()
|
||||
time_s = time()
|
||||
|
||||
Reference in New Issue
Block a user