@Retan0

Datetime time discord.py, время запуска программы?

Суть в чем,я создаю команду с аптаймом бота,создать ее,я то создал.Только вот не могу сделать время запуска бота.
Пытался разобраться,не очень получилось,вот код.

start_time = time.time()
current_time2 = datetime.now().time()

class things(commands.Cog):
    def __init__(self, client):
        self.client = client
        
    @commands.command(pass_context=True,aliases=["Info","Инфо"])
    async def info(self, ctx):
        count = 0
        for file in os.listdir('F:\\Rudy\\cogs'):
            if file.endswith('.py'):
                count = count + 1
            
        current_time = time.time()
        difference = int(round(current_time - start_time))
        dif2 = round(current_time2 - start_time)
        text = str(datetime.timedelta(seconds=difference))
        text2 = str(datetime.timedelta(seconds=dif2))
        embed=discord.Embed(title="Info", color=0x2edc90)
        embed.add_field(name="Uptime ", value=f"{text}", inline=True)
        embed.add_field(name="Startime", value=f"{text2}", inline=True)
        embed.add_field(name="Modules", value=f"{count}", inline=True)
        embed.set_footer(text="Python")
        await ctx.send(embed=embed)
        
    @commands.Cog.listener()
    async def on_ready(self):
        print("Модуль 'things.py' запущений ")
  • Вопрос задан
  • 203 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы