Skip to content

Commit ad4b366

Browse files
committed
Readme updated. Ready for release.
1 parent 8366149 commit ad4b366

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

README.rst

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,24 @@ This example will get a player with a certain tag, and search for 5 clans with a
5252
5353
5454
async def main():
55-
coc_client = coc.Client()
56-
try:
57-
await coc_client.login("email", "password")
58-
except coc.invalidcredentials as error:
59-
exit(error)
60-
61-
player = await client.get_player("tag")
62-
print(f"{player.name} has {player.trophies} trophies!")
63-
64-
clans = await client.search_clans(name="best clan ever", limit=5)
65-
for clan in clans:
66-
print(f"{clan.name} ({clan.tag}) has {clan.member_count} members")
67-
68-
try:
69-
war = await client.get_current_war("#clantag")
70-
print(f"{war.clan_tag} is currently in {war.state} state.")
71-
except coc.privatewarlog:
72-
print("uh oh, they have a private war log!")
73-
74-
# make sure to close the session or you will get asyncio
75-
# task pending errors
76-
await client.close()
55+
async with coc.Client() as coc_client:
56+
try:
57+
await coc_client.login("email", "password")
58+
except coc.invalidcredentials as error:
59+
exit(error)
60+
61+
player = await client.get_player("tag")
62+
print(f"{player.name} has {player.trophies} trophies!")
63+
64+
clans = await client.search_clans(name="best clan ever", limit=5)
65+
for clan in clans:
66+
print(f"{clan.name} ({clan.tag}) has {clan.member_count} members")
67+
68+
try:
69+
war = await client.get_current_war("#clantag")
70+
print(f"{war.clan_tag} is currently in {war.state} state.")
71+
except coc.privatewarlog:
72+
print("uh oh, they have a private war log!")
7773
7874
if __name__ == "__main__":
7975
try:

0 commit comments

Comments
 (0)