1- import brawlstats
21import asyncio
32
3+ import brawlstats
4+
45# Do not post your token on a public github!
56client = brawlstats .Client ('token' , is_async = True )
67
@@ -12,11 +13,15 @@ async def main():
1213 print (player .solo_victories ) # use snake_case instead of camelCase
1314
1415 club = await player .get_club ()
15- print (club .tag )
16- members = await club .get_members () # members sorted by trophies
17- best_players = members [:5 ] # gets best 5 players
18- for player in best_players :
19- print (player .name , player .trophies )
16+ if club is not None : # check if the player is in a club
17+ print (club .tag )
18+ members = await club .get_members () # members sorted by trophies
19+
20+ # gets best 5 players or returns all members if the club has less than 5 members
21+ index = max (5 , len (members ))
22+ best_players = members [:index ]
23+ for player in best_players :
24+ print (player .name , player .trophies ) # prints name and trophies
2025
2126 # get top 5 players in the world
2227 ranking = await client .get_rankings (ranking = 'players' , limit = 5 )
@@ -33,6 +38,7 @@ async def main():
3338 for player in ranking :
3439 print (player .name , player .rank )
3540
41+ # Gets a player's recent battles
3642 battles = await client .get_battle_logs ('GGJVJLU2' )
3743 print (battles [0 ].battle .mode )
3844
0 commit comments