From 568a0f9c390c69f699362a61f23b8fba3ed9ac61 Mon Sep 17 00:00:00 2001 From: Florian SYLVAIN Date: Sat, 30 Jan 2021 15:11:06 +0100 Subject: [PATCH] Add files via upload --- main.py | 31 ++++++++++++++----------------- riot_api.py | 28 ++++------------------------ 2 files changed, 18 insertions(+), 41 deletions(-) diff --git a/main.py b/main.py index 50510cd..d9e4e8f 100644 --- a/main.py +++ b/main.py @@ -13,27 +13,24 @@ print("Loading...") async def on_ready(): print('We have logged in as {0.user}'.format(bot)) -# @client.event -# async def on_message(message): -# if message.author == client.user: -# return - -# if message.content.startswith('$hello'): -# await message.channel.send('Hello!') - - -# @bot.command() -# async def test(ctx, arg): -# await ctx.send(arg) - @bot.command() async def rank(ctx, arg): try: player = watcher.summoner.by_name(region, arg) - text = rank_track(arg, player) - embed= discord.Embed(title=arg, url="https://www.youtube.com/watch?v=dQw4w9WgXcQ", description=text) - embed.set_thumbnail(url="http://ddragon.leagueoflegends.com/cdn/11.2.1/img/profileicon/" + str(player['profileIconId']) + ".png") - await ctx.send(embed=embed) + ranks = rank_track(arg, player) + + embed = discord.Embed(title = arg, url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ") + embed.set_thumbnail(url = "http://ddragon.leagueoflegends.com/cdn/11.2.1/img/profileicon/" + str(player['profileIconId']) + ".png") + + if ranks == list: + for i in range(len(ranks)): + text = str(ranks[i][1]) + ' ' + str(ranks[i][2]) + ' ' + str(ranks[i][3]) + ' LP' + '\n' + str(ranks[i][4]) + 'W/' + str(ranks[i][5]) + 'L' + embed.add_field(name = ranks[i][0], value = text, inline = False) + else: + embed.description = ranks + + await ctx.send(embed = embed) + except ApiError: await ctx.send("Le pseudo est inconnu ou un problème est survenu. (ma gestion des erreurs est à chier, déso pas déso)") diff --git a/riot_api.py b/riot_api.py index f086bd8..1941769 100644 --- a/riot_api.py +++ b/riot_api.py @@ -6,35 +6,15 @@ watcher = LolWatcher(token_riot) region = 'EUW1' def rank_track(nickname, player): - ranked_stats = watcher.league.by_summoner(region, player['id']) if not ranked_stats: - return str(nickname) + ' n\'est pas ranked.' + return 'Unranked cette saison.' else: + 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' - return infos['summonerName'] + ' est ' + str(infos['tier']) + ' ' + str(infos['rank']) + ' ' + str(infos['leaguePoints']) + ' LP en ' + str(what_rank) + '. ' + str(infos['wins']) + ' W / ' + str(infos['losses']) + 'L.' - -# def match_track(nickname, player): -# matche = watcher.match.matchlist_by_account(region, player['accountId']) -# last_match = matche['matches'][0] -# match_detail = watcher.match.by_id(region, last_match['gameId']) - -# print(match_detail) - -# def main(): -# while 1: -# nickname = str(input("Entrez votre pseudo league of legend : ")) -# try: -# player = watcher.summoner.by_name(region, nickname) -# rank_track(nickname, rank_track, player) -# # match_track(nickname, player) -# break -# except ApiError: -# print("Le pseudo est inconnu.") - -# if __name__ == '__main__': -# main() \ No newline at end of file + liste.append([what_rank, infos['tier'], infos['rank'], infos['leaguePoints'], infos['wins'], infos['losses']]) + return liste \ No newline at end of file