R
R
Retan02022-01-04 18:04:23
Python
Retan0, 2022-01-04 18:04:23

Datetime time discord.py, program start time?

The bottom line is, I create a team with a bot uptime, create it, I created it. But I can’t make the bot start time.
I tried to figure it out, it did not work out very well, here is the code.

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' запущений ")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question