33import codingame
44import discord
55import random
6+ import json
67from discord .colour import Color
78from discord .ext import commands
89
9- bot = commands .Bot (command_prefix = "!" )
10+ with open ("./config/config.json" , "r" ) as cjson :
11+ config = json .load (cjson )
12+ bot = commands .Bot (command_prefix = config ["prefix" ])
1013client = codingame .Client ()
1114
15+
1216@bot .event
1317async def on_command_error (ctx , error ):
1418 await ctx .send (f"An error occured: { str (error )} " )
@@ -22,10 +26,13 @@ async def on_ready():
2226 await bot .change_presence (activity = discord .Game (name = presence ))
2327 await asyncio .sleep (6 )
2428
25- @bot .command (name = "profile " )
26- async def profile (ctx , arg ):
29+ @bot .command (name = "profil " )
30+ async def profil (ctx , arg ):
2731 codingamer = client .get_codingamer (arg )
2832 embed = discord .Embed (title = codingamer .pseudo , url = "https://www.codingame.com/profile/" + codingamer .public_handle , color = 0xFF5733 )
33+ embed .add_field (name = "Clash Of Code Global rank:" , value = str (codingamer .get_clash_of_code_rank ()) + " ème" , inline = True )
34+ embed .add_field (name = "Global Rank" , value = str (codingamer .rank ) + " ème" , inline = True )
35+ embed .add_field (name = "Level:" , value = str (codingamer .level ), inline = False )
2936 embed .set_thumbnail (url = codingamer .avatar_url )
3037 await ctx .send (embed = embed )
3138
@@ -40,4 +47,4 @@ async def game(ctx):
4047 embed .set_footer (text = "Time before start: " + str (coc .time_before_start ))
4148 await ctx .send (embed = embed )
4249
43- bot .run ("/" )
50+ bot .run (config [ "token" ] )
0 commit comments