import discord import traceback import time import io class Extension: core = None def __init__(self, core): 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 = "" ): 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 embed: discord.Embed = player.embedNext if file and filename: embed.set_image(url=f"attachment://{filename}") return await interaction.followup.send(embed=embed, file=file, ephemeral=False) else: return await interaction.followup.send(embed=embed, ephemeral=False) 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