1212bot = commands .Bot (command_prefix = config ["prefix" ])
1313client = codingame .Client ()
1414
15-
1615@bot .event
1716async def on_command_error (ctx , error ):
1817 await ctx .send (f"An error occured: { str (error )} " )
@@ -36,14 +35,13 @@ async def profil(ctx, arg):
3635 embed .set_thumbnail (url = codingamer .avatar_url )
3736 await ctx .send (embed = embed )
3837
39-
4038@bot .command (name = "game" )
4139async def game (ctx ):
4240 coc = client .get_pending_clash_of_code ()
4341 embed = discord .Embed (title = "Click to join" , url = coc .join_url , description = "**Players online:**" , color = Color .blue ())
4442 embed .set_thumbnail (url = "https://res.cloudinary.com/crunchbase-production/image/upload/c_lpad,f_auto,q_auto:eco,dpr_1/v1410916443/e1aka8oyy6vnsbrt8ogw.png" )
4543 for player in coc .players :
46- embed .add_field (name = player .pseudo , value = "https://www.codingame.com/profile/" + player .public_handle )
44+ embed .add_field (name = player .pseudo , value = "[See profil]( https://www.codingame.com/profile/" + player .public_handle + ")" )
4745 embed .set_footer (text = "Time before start: " + str (coc .time_before_start .seconds ) + "s" )
4846 await ctx .send (embed = embed )
4947
@@ -60,11 +58,14 @@ async def next(ctx):
6058 await asyncio .sleep (next_battle + 5 )
6159 await ctx .send (ctx .author .mention )
6260 coc = client .get_pending_clash_of_code ()
61+ while not coc :
62+ coc = client .get_pending_clash_of_code ()
63+ asyncio .sleep (1 )
6364 embed = discord .Embed (title = "Click to join" , url = coc .join_url , description = "**Players online:**" , color = Color .blue ())
6465 embed .set_thumbnail (url = "https://res.cloudinary.com/crunchbase-production/image/upload/c_lpad,f_auto,q_auto:eco,dpr_1/v1410916443/e1aka8oyy6vnsbrt8ogw.png" )
6566 for player in coc .players :
6667 embed .add_field (name = player .pseudo , value = "https://www.codingame.com/profile/" + player .public_handle )
6768 embed .set_footer (text = "Time before start: " + str (coc .time_before_start ))
6869 await ctx .send (embed = embed )
6970
70- bot .run (config ["token" ])
71+ bot .run (config ["token" ])
0 commit comments