@ -9,43 +9,54 @@ class Extension:
self . core = core
@core . tree . command ( name = " profile " , description = " Проверить профиль " )
@discord . app_commands . describe ( profile = core . ANY_INPUT )
async def check_profile (
interaction : discord . Interaction ,
profile : str = " "
) :
await interaction . response . defer ( thinking = True )
player = await self . __call__ ( profile , interaction . user )
return await interaction . followup . send ( embed = player . embed , ephemeral = False )
@core . tree . command ( name = " profile_next " , description = " Проверить профиль NEW VERSION " )
@discord . app_commands . describe ( profile = core . ANY_INPUT )
async def check_profile_next (
interaction : discord . Interaction ,
profile : str = " "
) :
return await self . processMessage ( interaction , profile )
async def getPlayer ( self , profile : str , discord_user : discord . Member ) :
steam64 = await self . core . GetSteam64OfDiscord ( discord_user )
player = await self . core . GetPlayer ( profile , steam64 ) if profile else await self . core . GetPlayer ( steam64 , steam64 )
return player
async def processMessage ( self ,
interaction : discord . Interaction = None ,
profile : str = " " ,
message : discord . Message = None ,
discord_user : discord . Member = None
) :
if interaction :
await interaction . response . defer ( thinking = True )
player = await self . __call__ ( profile , interaction . user )
file = None
filename = None
if player . hasAnyConnect :
#create image if posible
try :
chartImage = await player . getGametimeViaImage ( )
filename = f " { player . steam64 } . { int ( time . time ( ) ) } .png "
print ( f " Size of image: { len ( chartImage ) } bytes " )
file = discord . File ( io . BytesIO ( chartImage ) , filename = filename )
except :
traceback . print_exc ( )
pass
player = await self . getPlayer ( profile , interaction . user if interaction else discord_user )
file = None
filename = None
if player . hasAnyConnect :
#create image if posible
try :
chartImage = await player . getGametimeViaImage ( )
filename = f " { player . steam64 } . { int ( time . time ( ) ) } .png "
print ( f " Size of image: { len ( chartImage ) } bytes " )
file = discord . File ( io . BytesIO ( chartImage ) , filename = filename )
except :
traceback . print_exc ( )
pass
embed : discord . Embed = player . embedNext
if file and filename :
embed . set_image ( url = f " attachment:// { filename } " )
embed : discord . Embed = player . embedNext
if file and filename :
embed . set_image ( url = f " attachment:// { filename } " )
if interaction :
return await interaction . followup . send ( embed = embed , file = file , ephemeral = False )
else :
if message :
return await message . channel . send ( embed = embed , file = file )
raise Exception ( ' Unknown processor ' )
else :
if interaction :
return await interaction . followup . send ( embed = embed , ephemeral = False )
if message :
return await message . channel . send ( embed = embed , ephemeral = False )
raise Exception ( ' Unknown processor ' )
async def __call__ ( self , profile : str , discord_user : discord . Member ) :
steam64 = await self . core . GetSteam64OfDiscord ( discord_user )
player = await self . core . GetPlayer ( profile , steam64 ) if profile else await self . core . GetPlayer ( steam64 , steam64 )
return player
async def __call__ ( self , * args , * * kwds ) :
return [ self . processMessage ]